Better scoring and map selection + Map delta
This commit is contained in:
@@ -14,6 +14,7 @@ class AiSimulation:
|
||||
|
||||
def __init__(self, game_map: Map):
|
||||
self.game = Game(deepcopy(game_map), GameState())
|
||||
self._base_map_types = self.game.map.to_type_dict()
|
||||
min_moves = self.game.map.get_min_moves()
|
||||
self.max_moves = min_moves * 2 if min_moves is not None else None
|
||||
self._condition = Condition()
|
||||
@@ -65,8 +66,18 @@ class AiSimulation:
|
||||
"moves": state.movesCount,
|
||||
"position": list(state.get_player_position()),
|
||||
"finished": state.stopGame,
|
||||
"changes": self._get_map_changes(),
|
||||
}
|
||||
|
||||
def _get_map_changes(self) -> list[dict]:
|
||||
current_map_types = self.game.map.to_type_dict()
|
||||
changes = []
|
||||
for y, row in enumerate(current_map_types):
|
||||
for x, block_type in enumerate(row):
|
||||
if block_type != self._base_map_types[y][x]:
|
||||
changes.append({"position": [x, y], "type": block_type})
|
||||
return changes
|
||||
|
||||
def close(self) -> None:
|
||||
self.stop_for_generation()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user