Example #1
0
    def test_should_initialize_game_with_light_of_power_and_thor(self):
        thor = Thor(10, 20)
        light_of_power = LightOfPower(15, 2)

        self.game = Game(thor, light_of_power)

        self.assertEqual(thor, self.game.thor)
        self.assertEqual(light_of_power, self.game.light_of_power)
Example #2
0
    def test_should_pick_south_east_when_light_of_power_is_below_and_diagonally_aligned_to_the_right_with_thor(self):
        pos_x, pos_y, expected_direction = 5, 1, "SE"
        light_of_power = LightOfPower(13, 5)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        computed_move = self.game.compute_move()

        self.assertEqual(expected_direction, computed_move)
Example #3
0
    def test_should_pick_south_when_light_of_power_is_below_and_aligned_vertically_with_thor(self):
        pos_x, pos_y, expected_direction = 6, 30, "S"
        light_of_power = LightOfPower(6, 40)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        computed_move = self.game.compute_move()

        self.assertEqual(expected_direction, computed_move)
Example #4
0
    def test_should_pick_west_when_light_of_power_is_behind_and_aligned_horizontally_with_thor(self):
        pos_x, pos_y, expected_direction = 10, 0, "W"
        light_of_power = LightOfPower(6, 0)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        computed_move = self.game.compute_move()

        self.assertEqual(expected_direction, computed_move)
Example #5
0
    def test_should_decrease_thors_position_in_y_when_heading_south(self):
        pos_x, pos_y, expected_pos_y = 4, 10, 11
        light_of_power = LightOfPower(15, 2)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        self.game.move("S")

        self.assertEqual(expected_pos_y, self.game.thor.pos_y)
Example #6
0
    def test_should_increase_thors_position_in_x_when_heading_east(self):
        pos_x, pos_y, expected_pos_x = 4, 10, 5
        light_of_power = LightOfPower(15, 2)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        self.game.move("E")

        self.assertEqual(expected_pos_x, self.game.thor.pos_x)
Example #7
0
    def test_should_pick_north_west_when_light_of_power_is_above_and_diagonally_aligned_to_the_left_with_thor(self):
        pos_x, pos_y, expected_direction = 15, 15, "NW"
        light_of_power = LightOfPower(7, 7)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        computed_move = self.game.compute_move()

        self.assertEqual(expected_direction, computed_move)
Example #8
0
def main():
    light_x, light_y, initial_tx, initial_ty = [int(i) for i in input().split()]
    light_of_power = LightOfPower(light_x, light_y)
    thor = Thor(initial_tx, initial_ty)
    game = Game(thor, light_of_power)

    while True:
        remaining_turns = int(input())
        if remaining_turns >= 0:
            direction = game.compute_move()

            print(direction)
            game.move(direction)
 def test_should_initialize_light_of_power_position(self):
     pos_x, pos_y = 4, 10
     self.light_of_power = LightOfPower(pos_x, pos_y)
     self.assertEqual(pos_x, self.light_of_power.pos_x)
     self.assertEqual(pos_y, self.light_of_power.pos_y)