本文整理汇总了Python中tile.Tile.create方法的典型用法代码示例。如果您正苦于以下问题:Python Tile.create方法的具体用法?Python Tile.create怎么用?Python Tile.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tile.Tile
的用法示例。
在下文中一共展示了Tile.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_best_action_for_board_state
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import create [as 别名]
def get_best_action_for_board_state( board, tiles_in_play ):
best_placement = Placement()
for tile_type in shuffle( get_my_unplayed_tile_types( board ) ):
valid_placement_positions = shuffle( board.get_valid_placements_for_tile( tile_type ) )
for placement_position in valid_placement_positions:
new_tile = Tile.create( tile_type, board.get_me() )
new_tile.set_position( placement_position, FakeBoard( tiles_in_play ) )
potential_new_tiles = tiles_in_play + [ new_tile ]
potential_new_tiles_score = score_tile_state( potential_new_tiles, board )
placement = Placement( tile_type, placement_position, potential_new_tiles_score )
if placement.score > best_placement.score:
best_placement = placement
best_movement = Movement()
for tile in shuffle( board.get_my_played_tiles() ):
valid_movement_positions = shuffle( board.get_valid_movements_for_tile( tile ) )
for movement_position in valid_movement_positions:
tiles_in_play.remove( tile )
new_tile = Tile.create( tile.type, board.get_me() )
new_tile.set_position( movement_position, FakeBoard( tiles_in_play ) )
potential_new_tiles = tiles_in_play + [ new_tile ]
potential_new_tiles_score = score_tile_state( potential_new_tiles, board )
movement = Movement( tile, movement_position, potential_new_tiles_score )
if movement.score > best_movement.score:
best_movement = movement
# Little bit of a hack - move any potential beetles off other tiles
new_tile.set_position( Position( [ 1000, 1000 ] ), FakeBoard( tiles_in_play ) )
tiles_in_play.append( tile )
if best_placement.score > 0 and best_placement.score > best_movement.score:
return best_placement
elif best_movement.score > 0:
return best_movement
return None
示例2: __init__
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import create [as 别名]
def __init__( self, player_number, ai_file ):
self.__player_number = player_number
self.__turn_number = 0
self.__ai_perform_move = imp.load_source( "", ai_file ).perform_move
self.__ai_file = ai_file
assert self.__ai_perform_move is not None
self.tiles = [
Tile.create( TileType.bee, self ),
Tile.create( TileType.beetle, self ),
Tile.create( TileType.beetle, self ),
Tile.create( TileType.spider, self ),
Tile.create( TileType.spider, self ),
Tile.create( TileType.ant, self ),
Tile.create( TileType.ant, self ),
Tile.create( TileType.ant, self ),
Tile.create( TileType.grass_hopper, self ),
Tile.create( TileType.grass_hopper, self ),
Tile.create( TileType.grass_hopper, self ),
]