Beispiel #1
0
def testManualGameImageOutput1():
    print("\n== init manual setting game ==")
    height = 10
    width = 10
    game = Game(height, width)

    obstacles = [{"x": 1, "y": 1}, {"x": 2, "y": 2}, {"x": 3, "y": 3}]
    targets = [{"x": 4, "y": 4}, {"x": 5, "y": 5}, {"x": 6, "y": 6}]
    game.setObstacles(obstacles)
    game.setTargets(targets)
    #game.setScore(100, 10, -0.01, -100)

    game.printGodMap()

    agents = {
        0: Agent(0, 7, 6, height, width, r=3),  # id, x, y, height, width
    }
    game.setAgents(agents)

    game.printConsoleMap()

    print("\n== 1st round ==")
    game.runOneRound([Command(0, -1, -1)])  # (6, 5)
    game.printConsoleMap()

    print("\n== 2st round ==")
    game.runOneRound([Command(0, -1, 0)])  # (5, 5)
    game.printConsoleMap()

    print("\n== 3st round ==")
    game.runOneRound([Command(0, -1, 0)])  #(4, 5)
    game.printConsoleMap()
Beispiel #2
0
def manualGame():
    print("\n== init manual setting game ==")
    height = 20
    width = 20
    game = Game(height, width)

    obstacles = [{"x": 1, "y": 1}, {"x": 2, "y": 2}, {"x": 3, "y": 3}]
    targets = [{"x": 10, "y": 10}, {"x": 12, "y": 12}, {"x": 13, "y": 13}]
    game.setObstacles(obstacles)
    game.setTargets(targets)

    agents = {
        0: Agent(0, 0, 0, height, width),  # id, x, y, height, width
        1: Agent(1, 14, 14, height, width),
        2: Agent(2, 15, 15, height, width),
    }
    game.setAgents(agents)
    game.setScore(100, 20, 10, -0.0005, 0, -20)

    game.printGodInfo()
    print("Score: " + str(game.outputScore()))

    print("\n== 1st round ==")
    commands = []
    commands.append(Command(0, 0, 1))  # id, dx, dy
    commands.append(Command(1, -1, 1))
    commands.append(Command(2, 1, -1))

    game.runOneRound(commands)

    game.printConsoleInfo()
    print("Score: " + str(game.outputScore()))

    print("\n== 2ed round ==")
    commands = []
    commands.append(Command(0, 1, 1))
    commands.append(Command(1, -1, 1))
    commands.append(Command(2, 1, -1))

    game.runOneRound(commands)

    game.printConsoleInfo()
    print("Score: " + str(game.outputScore()))

    print("\n== 3ed round ==")
    commands = []
    commands.append(Command(0, 1, 1))
    commands.append(Command(1, -1, 1))
    commands.append(Command(2, -1, 0))

    game.runOneRound(commands)

    game.printConsoleInfo()
    print("Score: " + str(game.outputScore()))