Beispiel #1
0
 def applyHeuristic(self, game: Game) -> Game:
     cityListId = game.citiesOf(self.isRedPlayer)
     bonusArmy = game.bonusSoldiers(self.isRedPlayer)
     minimumTerritor = self.calculateMinimumTerritory(cityListId, game)
     if minimumTerritor != None:
         game.addSoldiersToCity(minimumTerritor.id, bonusArmy)
     return game
Beispiel #2
0
 def applyHeuristic(self, game: Game) -> Game:
     cityListId = game.citiesOf(self.isRedPlayer)
     bonusArmy = game.bonusSoldiers(self.isRedPlayer)
     maxCity = self.calculateMaxCity(cityListId, game)
     if maxCity != None:
         game.addSoldiersToCity(maxCity.id, bonusArmy)
     # attack all neighbour cities with most armies
     for cityId in cityListId:
         for neighbourId in game.map.graph[cityId]:
             neighbour = game.cityList[neighbourId]
             city = game.cityList[cityId]
             if neighbour.armyCount < city.armyCount - 1 and neighbour.isRedArmy != city.isRedArmy:
                 game.move(city.id, neighbour.id, city.armyCount - 1)
     return game
Beispiel #3
0
 def rollBack(self, game: Game):
     game.addSoldiersToCity(self.toId, -self.attackers)
     game.addSoldiersToCity(self.fromId, self.attackers)
     game.changeCityOwner(self.toId)
     game.addSoldiersToCity(self.toId, self.defenders)
Beispiel #4
0
 def apply(self, game: Game):
     game.addSoldiersToCity(self.cityId, self.soldiers)
Beispiel #5
0
 def rollBack(self, game: Game):
     game.addSoldiersToCity(self.cityId, -self.soldiers)