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)
Ejemplo n.º 2
0
from aot.model.condition import *
from aot.model.effect import *
from aot.model.unit import Unit
from aot.model.enums.player import PlayerEnum
from aot.model.enums.sizes import Size
from aot.model.enums.tile import EnumTile
from aot.model.enums.unit import UnitConstant, UnitType
from aot.model.scenario import Scenario
from aot.model.trigger import Trigger
from aot.utilities.configuration import Configuration
import logging
import numpy as np
import random

logging.basicConfig(level=logging.INFO)
C = Configuration("examples/configuration_de.json")

scn = Scenario(size=Size.TINY)
scn.load_template(Size.TINY)

test = Trigger("Build Wonder Time (need change)", enable=1, loop=False)
test.then_(ModifyAttribute(source_player=1))
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))
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

logger = logging.getLogger(__name__)
C = Configuration("config.json")

logging.basicConfig(level=logging.DEBUG)

copy = Scenario(size=Size.GIANT)
copy.load(C.game_path_scenario, "test_display_instruction")
copy.save(C.game_path_scenario, "test_display_instruction_copy")
true = Scenario(size=Size.GIANT)
true.load(C.game_path_scenario, "test_display_instruction")

copy = Scenario(size=Size.GIANT)
copy.load(C.game_path_scenario, "test_display_instruction_copy")

print(compare_scenario_files(copy, true, header=True))
print(compare_scenario_files(copy, true, header=False))
Ejemplo n.º 4
0
import logging
import numpy as np

from aot import Scenario, UnitConstant
from aot.model.enums.sizes import Size
from aot.utilities.configuration import Configuration

C = Configuration("aot/api/examples/configuration_de.json")
scn = Scenario(size=Size.GIANT)
y_area = 50
x_area = 50
castles = []
loots = []
quarries = []
lumbers = []
army_tents = []
pavilions = []
for p in range(0, 9):
    for unit in scn.players[p].units:
        x = int(unit.x)
        y = int(unit.y)
        if unit.type == UnitConstant.CASTLE.value:
            castles.append((x - 2, y - 2))
        elif unit.type == UnitConstant.LOOT.value:
            loots.append((x, y))
        elif unit.type == UnitConstant.LUMBER.value:
            lumbers.append((x, y))
        elif unit.type == UnitConstant.QUARRY.value:
            quarries.append((x, y))
        elif unit.type == UnitConstant.ARMY_TENT_1.value or unit.type == UnitConstant.ARMY_TENT_2.value:
            army_tents.append((x, y))
Ejemplo n.º 5
0
import numpy as np

import logging
from aot import Scenario
from aot.metatriggers.metatrigger_treasure import TreasureLoot, TreasureQuarry, TreasureLumber
from aot.utilities.configuration import Configuration

logging.basicConfig(level=logging.DEBUG)
C = Configuration("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")