Example #1
0
def test_ship_collision4():

    game = Game(wait_agent, wait_agent)
    s1 = Ship(10, 11, game.players[0])
    s1.halite = 10
    s2 = Ship(10, 11, game.players[1])
    s2.halite = 10
    game.players[0].add_ship(s1)
    game.players[1].add_ship(s2)

    assert len(game.players[0].ships) == 2
    assert len(game.players[0].ship_array[11][10]) == 1

    assert len(game.players[1].ships) == 2
    assert len(game.players[1].ship_array[11][10]) == 1

    assert game.get_halite(s1.x, s1.y) == 0

    game.ship_collisions()

    assert len(game.players[0].ships) == 1
    assert len(game.players[0].ship_array[11][10]) == 0

    assert len(game.players[1].ships) == 1
    assert len(game.players[1].ship_array[11][10]) == 0

    assert game.get_halite(s1.x, s1.y) == 20
Example #2
0
def test_ship_collision1():

    game = Game(wait_agent, wait_agent)
    s1 = Ship(10, 11, game.players[0])
    s1.halite = 10
    s2 = Ship(10, 11, game.players[0])
    s2.halite = 20
    game.players[0].add_ship(s1)
    game.players[0].add_ship(s2)

    assert len(game.players[0].ships) == 3
    assert len(game.players[0].ship_array[11][10]) == 2

    game.ship_collisions()

    assert len(game.players[0].ships) == 2
    assert len(game.players[0].ship_array[11][10]) == 1
    assert game.players[0].ship_array[11][10][0] == s1
    assert s1.halite == 30