コード例 #1
0
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")
コード例 #2
0
        self.other_team = None
        self.players_starts = [None] * 8


class Player:
    def __init__(self, id):
        self.id = id
        self.position = (None, None)


team1 = Team("TEAM 1")
team1.players = [Player(i) for i in range(1, 9)]

#Size
width = scn.get_width()
height = scn.get_height()

for x in range(0, width):
    for y in range(0, height):
        scn.map.tiles[x][y].type = EnumTile.NOBUILDING.value

#Diplomacy
diplomacy = Trigger("Set Diplomacy", enable=1).then_(
    SendInstruction(message="Welcome to The War of Trebuchet.",
                    color=Color.ORANGE,
                    panel_location=0,
                    time=30)
).then_(
    SendInstruction(
        message=
        "Build a Wonder to obtain Trebuchets or Cannon Galleons. Build a Castle to obtain Flamming Camels or Photonmen.",
コード例 #3
0
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)
#         scn.map.tiles[x + x_offset][y + y_offset].type = EnumTile.WATER_SHALLOW.value