Esempio n. 1
0
def run_battle(player_modules,
               speed=150,
               asteroids_count=50,
               drones_count=5,
               show_screen=False):
    scene = SpaceField(
        speed=speed,
        field=(1200, 1200),
        asteroids_count=asteroids_count,
        can_fight=True,
        headless=not show_screen,
    )
    scene._Scene__teams = OrderedDict()
    drones_teams = {}
    drones_paths = {}
    for i, team_module in enumerate(player_modules):
        module_to_import = team_module.replace('.py',
                                               '').replace('/', '.').replace(
                                                   '\\', '.')
        drone_module = importlib.import_module(module_to_import)
        if not hasattr(drone_module, 'drone_class'):
            raise ValueError(
                f'In module {team_module} no variable drone_class: cant import drones!!!'
            )
        drone = drone_module.drone_class
        drones_paths[drone.__name__] = team_module
        drones_teams[i] = [drone() for _ in range(drones_count)]
    battle_result = scene.go()
    battle_result['players_modules'] = drones_paths
    return battle_result
Esempio n. 2
0
# -*- coding: utf-8 -*-

# pip install -r requirements.txt

from astrobox.space_field import SpaceField
from stage_03_harvesters.reaper import ReaperDrone
# TODO тут импортировать своих дронов
from vader import VaderDrone

NUMBER_OF_DRONES = 5

if __name__ == '__main__':
    scene = SpaceField(
        speed=5,
        asteroids_count=20,
    )
    # TODO создать их
    team_1 = [VaderDrone() for _ in range(NUMBER_OF_DRONES)]
    # TODO и побороть противников!
    team_2 = [ReaperDrone() for _ in range(NUMBER_OF_DRONES)]
    scene.go()

Esempio n. 3
0
        if self.have_gun:
            if self.is_strategy_finished():
                self.append_strategy(StrategyHarvesting(unit=self))


class CowardDrone(DestroyerDrone):
    def on_born(self):
        self.append_strategy(StrategyHarvesting(unit=self))


if __name__ == '__main__':
    space_field = SpaceField(
        name="Space war",
        speed=5,
        field=(1600, 800),
        asteroids_count=30,
        can_fight=True,
        max_drones_at_team=12,
        # headless=True,
    )

    DRONES_COUNT = 5

    teamA = [WorkerDrone() for _ in range(DRONES_COUNT)]
    # teamB = [GreedyDrone() for _ in range(DRONES_COUNT)]
    teamC = [HunterDrone() for _ in range(DRONES_COUNT)]
    teamD = [DestroyerDrone() for _ in range(DRONES_COUNT)]
    # teamD.extend(CowardDrone() for _ in range(5))

    space_field.go()
Esempio n. 4
0
def main():
    # KarpovDrone.set_logger()
    scene = SpaceField(speed=3, asteroids_count=10)
    drones = [KarpovDrone() for _ in range(DRONES_QTY)]
    scene.go()
Esempio n. 5
0
from astrobox.space_field import SpaceField

from side_projects.astro_game.my_drone import MyDrone

if __name__ == '__main__':
    my_space = SpaceField(
        field=(1200, 900),
        speed=2,
        asteroids_count=7
    )

    my_drones = [MyDrone() for _ in range(5)]

    my_space.go()