def test_monster_move(self):
     my_cave = parse_cave_input('data/test15_move.txt')
     elf = my_cave.elves[0]
     self.assertEqual(elf.location, (1, 1))
     my_cave.tick()
     self.assertEqual(elf.location, (2, 1))
 def test_run_cave_game_1(self):
     cave = parse_cave_input('data/test15_1.txt')
     self.assertEqual(run_cave_game(cave), 27730)
 def test_run_cave_game_6(self):
     cave = parse_cave_input('data/test15_6.txt')
     self.assertEqual(run_cave_game(cave), 18740)
 def test_run_cave_game_5(self):
     cave = parse_cave_input('data/test15_5.txt')
     self.assertEqual(run_cave_game(cave), 28944)
 def test_run_cave_game_3(self):
     cave = parse_cave_input('data/test15_3.txt')
     self.assertEqual(run_cave_game(cave), 39514)
 def test_run_cave_game_2(self):
     cave = parse_cave_input('data/test15_2.txt')
     self.assertEqual(run_cave_game(cave), 36334)
Пример #7
0
from day15_1 import parse_cave_input, run_cave_game

if __name__ == '__main__':
    outcome = -1
    elf_power = 3
    while outcome == -1:
        cave = parse_cave_input('data/input15.txt')
        elf_power += 1
        for elf in cave.elves:
            elf.power = elf_power
        print(f'running with elf power: {elf_power}')
        outcome = run_cave_game(cave, abort_on_elf_death=True)

    print(f'No elves died with power {elf_power} for an outcome of {outcome}')