Ejemplo n.º 1
0
 def test__ant_on_field(self):
     config = DictionaryConfigProvider()
     config.SetValue('InitialPosition', 'InitialDirection', 0)
     config.SetValue('InitialPosition', 'InitialPosition_x', 1)
     config.SetValue('InitialPosition', 'InitialPosition_y', 1)
     processor = AntStepProcesser(config)
     processor.process_ant_step(99, StepEnum.NoStep)
     is_on_field = processor.is_ant_on_field(99)
     self.assertTrue(is_on_field)
Ejemplo n.º 2
0
 def test__from_north_step_back(self):
     config = DictionaryConfigProvider()
     config.SetValue('InitialPosition', 'InitialDirection', 0)
     config.SetValue('InitialPosition', 'InitialPosition_x', 1)
     config.SetValue('InitialPosition', 'InitialPosition_y', 1)
     processor = AntStepProcesser(config)
     processor.process_ant_step(99, StepEnum.Back)
     position_data = processor.get_ant_position_and_direction(99)
     self.assertTrue(position_data[1] == 2)
Ejemplo n.º 3
0
 def test__initial_step_turn(self):
     config = DictionaryConfigProvider()
     config.SetValue('InitialPosition', 'InitialDirection', 0)
     config.SetValue('InitialPosition', 'InitialPosition_x', 1)
     config.SetValue('InitialPosition', 'InitialPosition_y', 1)
     processor = AntStepProcesser(config)
     processor.process_ant_step(99, StepEnum.TurnRight)
     position_data = processor.get_ant_position_and_direction(99)
     self.assertTrue(position_data[2] == DirectionsEnum.East)
Ejemplo n.º 4
0
 def test__from_east_step_forward(self):
     config = DictionaryConfigProvider()
     config.SetValue('InitialPosition', 'InitialDirection', 0)
     config.SetValue('InitialPosition', 'InitialPosition_x', 1)
     config.SetValue('InitialPosition', 'InitialPosition_y', 1)
     processor = AntStepProcesser(config)
     processor.process_ant_step(99, StepEnum.TurnRight)
     processor.process_ant_step(99, StepEnum.Forward)
     position_data = processor.get_ant_position_and_direction(99)
     self.assertTrue(position_data[0] == 2)
Ejemplo n.º 5
0
 def test__y_negetive_south_facing_axis_movment(self):
     config = DictionaryConfigProvider()
     config.SetValue('InitialPosition', 'InitialDirection', 1)
     config.SetValue('InitialPosition', 'InitialPosition_x', 1)
     config.SetValue('InitialPosition', 'InitialPosition_y', 1)
     processor = AntStepProcesser(config)
     processor.process_ant_step(99, StepEnum.NoStep)
     translate = TranslateStep(config, processor)
     step = AntStep(99, Position(1, 0))
     movment = translate.TranlateStep(step)
     self.assertTrue(movment[0] == StepEnum.Back)
Ejemplo n.º 6
0
 def test__x_positive_east_facing_axis_movment(self):
     config = DictionaryConfigProvider()
     config.SetValue('InitialPosition', 'InitialDirection', 2)
     config.SetValue('InitialPosition', 'InitialPosition_x', 1)
     config.SetValue('InitialPosition', 'InitialPosition_y', 1)
     processor = AntStepProcesser(config)
     processor.process_ant_step(99, StepEnum.NoStep)
     translate = TranslateStep(config, processor)
     step = AntStep(99, Position(2, 1))
     movment = translate.TranlateStep(step)
     self.assertTrue(len(movment) == 1)
     self.assertTrue(movment[0] == StepEnum.Forward)
Ejemplo n.º 7
0
 def test__initial_ant_and_no_ant(self):
     config = DictionaryConfigProvider()
     config.SetValue('InitialPosition', 'InitialDirection', 0)
     config.SetValue('InitialPosition', 'InitialPosition_x', 1)
     config.SetValue('InitialPosition', 'InitialPosition_y', 1)
     processor = AntStepProcesser(config)
     processor.process_ant_step(99, StepEnum.NoStep)
     position_data = processor.get_ant_position_and_direction(99)
     self.assertTrue(position_data[0] == 1 and position_data[1] == 1
                     and position_data[2] == DirectionsEnum.North)
     position_data = processor.get_ant_position_and_direction(100)
     self.assertTrue(position_data[0] == -1 and position_data[1] == -1
                     and position_data[2] == -1)
Ejemplo n.º 8
0
 def test__complex_set_2(self):
     config = DictionaryConfigProvider()
     config.SetValue('InitialPosition', 'InitialDirection', 0)
     config.SetValue('InitialPosition', 'InitialPosition_x', 1)
     config.SetValue('InitialPosition', 'InitialPosition_y', 1)
     processor = AntStepProcesser(config)
     processor.process_ant_step(99, StepEnum.Back)
     processor.process_ant_step(99, StepEnum.Back)
     processor.process_ant_step(99, StepEnum.TurnRight)
     processor.process_ant_step(99, StepEnum.Forward)
     processor.process_ant_step(99, StepEnum.TurnRight)
     processor.process_ant_step(99, StepEnum.Back)
     position_data = processor.get_ant_position_and_direction(99)
     self.assertTrue(position_data[0] == 2)
     self.assertTrue(position_data[1] == 2)
     self.assertTrue(position_data[2] == DirectionsEnum.South)