예제 #1
0
파일: board.py 프로젝트: henriksu/qwirkle
 def remaining_tiles(self):
     """Returns a set of tiles that could still be played,
     that is less than three instances of it is found on the board.
     """
     tiles = Tile.set_of_all_tiles()
     result = set()
     count = Counter(self.tiles_list)
     for tile in tiles:
         if count[tile] < 3:
             result.add(tile)
     return result
예제 #2
0
파일: board.py 프로젝트: henriksu/qwirkle
 def _legal_tiles(self, adjacent_position, tiles=None):
     """Given a Position, this method returns the set
     of tiles that can be placed there.
     """
     #         # 0.1 check not occupied
     #         if adjacent_position in self.positions:
     #             raise ValueError('Position already occupied.')
     #         # 0.2 check actually adjacent.
     #         neighbours = adjacent_position.neighbour_positions()
     #         for pos in neighbours:
     #             if pos in self.positions:
     #                 break
     #         else:
     #             raise ValueError('Position not adjacent to any tile.')
     # 1. For each adjacent strike, find set of allowed continuations.
     if tiles is None:
         tiles = Tile.set_of_all_tiles()
     result = set()
     for tile in tiles:
         if Move(self, [(adjacent_position, tile)]).is_allowed():
             result.add(tile)
     return result