Пример #1
0
    def test_putGridItem(self):
        # arrange
        bb = BeverageBandidts()

        # act
        bb.putGridItem('t', 2, 2)

        # assert
        self.assertEqual(bb.getGridItem(2, 2), 't')
Пример #2
0
    def test_grid_print(self):
        # arrange
        bb = BeverageBandidts()

        # act
        bb.load(test1)

        # assert
        bb.printGrid()
        bb.doRound()
        bb.printGrid()

        self.assertTrue(True)
Пример #3
0
    def test_get_nearest(self):
        # arrange
        bb = BeverageBandidts()
        bb.load(test1)
        result = []
        # act
        goblin11 = bb.getUnitAt(1, 1)
        result.append(bb.getNearestTo(goblin11))
        goblin77 = bb.getUnitAt(7, 7)
        result.append(bb.getNearestTo(goblin77))

        # assert
        self.assertEqual(result, [bb.getUnitAt(4, 4), bb.getUnitAt(4, 5)])
Пример #4
0
    def test_load_data(self):
        # arrange
        bb = BeverageBandidts()

        # act
        bb.load(test1)

        # assert
        self.assertEqual(bb.numGoblins(), 8)
        self.assertEqual(bb.numElfs(), 2)
        self.assertEqual(bb.numGoblins(), 8)
Пример #5
0
    def test_directionTo(self):
        # arrange
        bb = BeverageBandidts()
        goblin = Goblin(2, 2)
        elf00 = Elf(0, 0)
        elf1010 = Elf(10, 10)
        elf010 = Elf(0, 10)
        elf100 = Elf(10, 0)
        elf23 = Elf(2, 3)

        result = []

        #act
        result.append(bb.directionTo(goblin, elf00).a())
        result.append(bb.directionTo(goblin, elf1010).a())
        result.append(bb.directionTo(goblin, elf010).a())
        result.append(bb.directionTo(goblin, elf100).a())
        result.append(bb.directionTo(goblin, elf23).a())

        # assert
        self.assertEqual(result, [[-1, -1], [1, 1], [-1, 1], [1, -1], [0, 1]])
Пример #6
0
    def test_distanceTo(self):
        # arrange
        bb = BeverageBandidts()
        goblin = Goblin(2, 2)
        elf00 = Elf(0, 0)
        elf1010 = Elf(10, 10)
        elf010 = Elf(0, 10)
        elf100 = Elf(10, 0)
        elf23 = Elf(2, 3)

        result = []

        #act
        result.append(bb.distanceTo(goblin, elf00))
        result.append(bb.distanceTo(goblin, elf1010))
        result.append(bb.distanceTo(goblin, elf010))
        result.append(bb.distanceTo(goblin, elf100))
        result.append(bb.distanceTo(goblin, elf23))

        # assert
        self.assertEqual(result, [4, 16, 10, 10, 1])
Пример #7
0
# Advent of Code 2018: https://adventofcode.com/2018/day/15
#
# Main file

import datetime, time
from datetime import timedelta

from AoC15_classes import BeverageBandidts
start = datetime.datetime.now()

inputData = open('../../data/input15.txt', 'r')
liveData = inputData.readlines()

bb = BeverageBandidts()
bb.load(liveData)

scores = bb.getScores()

print('\nPart 1: The outcome of the combat is', inputData, 'is', scores)

# print('\nPart 2: The location of the last cart is', cart.print())

end = datetime.datetime.now()
duration = end - start
print('Completed in {0:02d}:{1:02d}:{2:02.5f}\n'.format(
    int(duration.seconds / 3600), int(duration.seconds / 60),
    duration.seconds % 60 + duration.microseconds / 1000000))