from aot.model.effect import * from aot.model.trigger import Trigger from aot.model.enums.sizes import Size from aot.model.scenario import Scenario from aot.utilities.configuration import Configuration import logging from test.test_api.compare import compare_scenario_files logging.basicConfig(level=logging.DEBUG) C = Configuration("test/dirty_tests/config.json") scn = Scenario(size=Size.GIANT) scn.load_template(Size.GIANT) scn.add( Trigger("Trigger 0", enable=1).then_( SendInstruction(message="Hello instruction !!!! (from true file)"))) scn.add( Trigger("Trigger 1", enable=1).then_( SendInstruction(message="Hello instruction 2 !!!! (from true file)"))) scn.save(C.game_path_scenario, "test_instruction_from_scratch") copy = Scenario(size=Size.GIANT) copy.load(C.game_path_scenario, "test_instruction_from_scratch") true = Scenario(size=Size.GIANT) true.load(C.game_path_scenario, "hello_instruction") compare_scenario_files(copy, true, header=True) compare_scenario_files(copy, true, header=False)
import numpy as np import logging from aot.model.scenario import Scenario from aot.model.unit import Unit from aot.meta_triggers.metatrigger_treasure import TreasureLoot, TreasureQuarry, TreasureLumber from aot.utilities.configuration import Configuration logging.basicConfig(level=logging.DEBUG) C = Configuration("examples\configuration_de.json") scn = Scenario() for _ in range(100): n = np.random.random() x = int(np.random.random() * scn.get_width()) y = int(np.random.random() * scn.get_height()) if n < 0.33: treasure = TreasureLoot(x, y, 500) elif n < 0.66: treasure = TreasureLumber(x, y, 500) else: treasure = TreasureQuarry(x, y, 500) scn.add(treasure) scn.save(C.game_path_scenario, "random_tresures")
test.then_(ModifyAttribute(source_player=2)) test.then_(ModifyAttribute(source_player=3)) test.then_(ModifyAttribute(source_player=4)) test.then_(ModifyAttribute(source_player=5)) test.then_(ModifyAttribute(source_player=6)) test.then_(ModifyAttribute(source_player=7)) test.then_(ModifyAttribute(source_player=8)) test.then_(ModifyAttributeCastle(source_player=1)) test.then_(ModifyAttributeCastle(source_player=2)) test.then_(ModifyAttributeCastle(source_player=3)) test.then_(ModifyAttributeCastle(source_player=4)) test.then_(ModifyAttributeCastle(source_player=5)) test.then_(ModifyAttributeCastle(source_player=6)) test.then_(ModifyAttributeCastle(source_player=7)) test.then_(ModifyAttributeCastle(source_player=8)) scn.add(test) #Team class Team: def __init__(self, name): self.name = name self.x1_win = None self.x2_win = None self.y1_win = None self.y2_win = None self.players = None self.other_team = None self.players_starts = [None] * 8
time=5)) for team in [team1, team2]: for player in team.players: for target_player in team.other_team.players: diplomacy.then_( ChangeDiplomacy(source_player=player.id, target_player=target_player.id, diplomacy=3)) for target_player in team.players: diplomacy.then_( ChangeDiplomacy(source_player=player.id, target_player=target_player.id, diplomacy=0)) scn.add(diplomacy) HEIGHT_BATTEFIELD = scn.get_height() - 2 * SPAWN_LENGTH WIDTH_BATTLE_FIELD = scn.get_width() - 1 # generate terrain x_offset = 0 y_offset = SPAWN_LENGTH # for w in range(NUMBER_OF_LACS): # i = np.random.randint(3, WIDTH_BATTLE_FIELD - 3) # j = np.random.randint(3, HEIGHT_BATTEFIELD - 3) # for _ in range(200): # sigma = 4 # x = min(max(3, int(np.random.normal(i, sigma, 1))), WIDTH_BATTLE_FIELD - 3) # y = min(max(3, int(np.random.normal(j, sigma, 1))), HEIGHT_BATTEFIELD - 3)