Esempio n. 1
0
 def is_near_to_element(self, x, y, elem):
     _is_near = False
     if not Point(x, y).is_bad(self._size):
         _is_near = (self.has_element_at(x + 1, y, elem)
                     or self.has_element_at(x - 1, y, elem)
                     or self.has_element_at(x, 1 + y, elem)
                     or self.has_element_at(x, 1 - y, elem))
     return _is_near
Esempio n. 2
0
 def get_count_elements_near_to_point(self, x, y, elem):
     """ Counts the number of occurencies of elem nearby """
     _near_count = 0
     if not Point(x, y).is_bad(self._size):
         for _x, _y in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)):
             if self.has_element_at(_x, _y, elem):
                 _near_count += 1
     return _near_count
Esempio n. 3
0
def check_moves(board: Board, current: Point):
    moves = {(1, 0),(0, 1),(-1, 0),(0, -1)}
    available_moves = []
    for move in moves:
        new = Point(current.get_x() + move[0], current.get_y() + move[1])
        if is_possible_move(board, current, new):
            available_moves.append(new)
    return available_moves
Esempio n. 4
0
 def has_pipe_at(self, x, y):
     char = self.char_at(x, y)
     if (char == _ELEMENTS['PIPE']):
         return True
     if (char == _ELEMENTS['HERO_PIPE_LEFT']):
         return True
     if (char == _ELEMENTS['HERO_PIPE_RIGHT']):
         return True
     if (char == _ELEMENTS['OTHER_HERO_PIPE_LEFT']):
         return True
     if (char == _ELEMENTS['OTHER_HERO_PIPE_RIGHT']):
         return True
     if (char == _ELEMENTS['ENEMY_PIPE_LEFT']):
         return True
     if (char == _ELEMENTS['ENEMY_PIPE_RIGHT']):
         return True
     return False
     return Point(x, y) in self.get_pipe_positions()
Esempio n. 5
0
 def is_barrier_at(self, x, y):
     """ Return true if barrier is at x,y."""
     return Point(x, y) in self.get_barriers()
Esempio n. 6
0
 def _strpos2pt(self, strpos):
     return Point(*self._strpos2xy(strpos))
Esempio n. 7
0
 def has_shadow_at(self, x, y):
     return Point(x, y) in self.__get_shadows()
Esempio n. 8
0
 def has_pipe_at(self, x, y):
     return Point(x, y) in self.get_pipe_positions()
Esempio n. 9
0
 def has_gold_at(self, x, y):
     return Point(x, y) in self.get_gold_positions()
Esempio n. 10
0
 def has_ladder_at(self, x, y):
     return Point(x, y) in self.get_ladder_positions()
Esempio n. 11
0
 def has_wall_at(self, x, y):
     return Point(x, y) in self.get_wall_positions()
Esempio n. 12
0
 def has_other_hero_at(self, x, y):
     return Point(x, y) in self.get_other_hero_positions()
Esempio n. 13
0
 def has_enemy_at(self, x, y):
     return Point(x, y) in self.get_enemy_positions()