Esempio n. 1
0
 def walkable(self, x, y):
     tile = self.v.get(num(x, y))
     return 0 <= x < w() and \
         0 <= y < h() and \
         tile != TT.WALL and \
         tile != TT.ROCK and \
         tile != TT.CLL
Esempio n. 2
0
 def walkable(self, x, y):
     tile = self.v.get(num(x, y))
     return 0 <= x < w() and \
         0 <= y < h() and \
         tile != TT.WALL and \
         tile != TT.ROCK and \
         tile != TT.CLL
Esempio n. 3
0
 def walkable(self, tile):
     (x, y) = tup(tile)
     return True if x < w() and x >= 0 and y < h() and y >= 0 and\
                    self.v.get(num(x, y)) != TileType.WALL    and\
                    self.v.get(num(x, y)) != TileType.ROCK    and\
                    self.v.get(num(x, y)) != TileType.CLL        \
                 else False
Esempio n. 4
0
 def walkable(self, tile):
     (x, y) = tup(tile)
     tile_type = self.v.get(tile)
     return 0 <= x < w() and \
         0 <= y < h() and \
         tile_type != TT.WALL and \
         tile_type != TT.ROCK and \
         tile_type != TT.CLL
Esempio n. 5
0
    def get_adjacent_tiles_cost(self, tile):
        adj_set = set()

        # above
        if self.walkable(tile - w()):
            adj_set.add((tile - w(), 1))  # want to go up
        # below
        if self.walkable(tile + w()):
            adj_set.add((tile + w(), 4))  # don't want to go under
        # left
        if self.walkable(tile - 1):
            adj_set.add((tile - 1, 2))    # don't care about side steps
        # right
        if self.walkable(tile + 1):
            adj_set.add((tile + 1, 2))    # don't care about side steps

        return adj_set
Esempio n. 6
0
 def walkable(self, x, y):
     return (
         True
         if x < w()
         and x >= 0
         and y < h()
         and y >= 0
         and self.v.get(num(x, y)) != TileType.WALL
         and self.v.get(num(x, y)) != TileType.ROCK
         and self.v.get(num(x, y)) != TileType.CLL
         else False
     )
Esempio n. 7
0
    def above_water(self):
        above = set()
        y = self.m.water + 1
        
        if y >= h():
            return None

        for x in range(w()):
            t = num(x, y)
            if self.walkable(t):
                above.add(t)
        return above
Esempio n. 8
0
    def get_adjacent_tiles_cost(self, tile):

       adj_set = set()

       # above
       if self.walkable(tile - w()):
           adj_set.add((tile - w(), 1))

       # below
       if self.walkable(tile + w()):
           adj_set.add((tile + w(), 4))

       # left
       if self.walkable(tile - 1):
           adj_set.add((tile - 1, 2))

       # right
       if self.walkable(tile + 1):
           adj_set.add((tile + 1, 2))

       return adj_set
Esempio n. 9
0
    def above_water(self):
        above = set()
        y = self.m.water + 1
        
        if y >= h():
            return above

        for x in range(w()):
            t = num(x, y)
            if self.walkable(t):
                above.add(t)
        return above
Esempio n. 10
0
 def get_all_lambdas(self):
     list_lambdas = set()
     for i in range(h() * w()):
         if self.v.get(i) == TileType.LAMBDA:
             list_lambdas.add(tup(i))
     return list_lambdas
Esempio n. 11
0
 def get_all_lambdas(self):
     list_lambdas = set()
     for i in range(h() * w()):
         if self.v.get(i) == TT.LAMBDA:
             list_lambdas.add(tup(i))
     return list_lambdas