示例#1
0
 def test_first_step_from_unactivated_origin_with_dir_up_is_right(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.dir = "up"
     ant.step()
     self.assertEqual(1, ant.x)
     self.assertEqual(0, ant.y)
示例#2
0
 def test_ant_get_current_activation_returns_true_if_square_activated(self):
     ant = AntGrid()
     ant.x, ant.y = 1, 3
     square_1_3 = Square(x=1, y=3)
     square_1_3.activated = True
     ant.grid_list = [square_1_3]
     self.assertEqual(True, ant.current_activation())
示例#3
0
 def test_first_step_from_unactivated_origin_with_dir_up_is_right(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.dir = "up"
     ant.step()
     self.assertEqual(1, ant.x)
     self.assertEqual(0, ant.y)
示例#4
0
 def test_ant_get_current_activation_returns_true_if_square_activated(self):
     ant = AntGrid()
     ant.x, ant.y = 1, 3
     square_1_3 = Square(x=1, y=3)
     square_1_3.activated = True
     ant.grid_list = [square_1_3]
     self.assertEqual(True, ant.current_activation())
示例#5
0
 def test_ant_get_current_activation_returns_state_of_correct_square(self):
     ant = AntGrid()
     ant.x, ant.y = 3, 4
     square_0_0 = Square(x=0, y=0)
     square_0_1 = Square(x=0, y=1)
     square_3_4 = Square(x=3, y=4)
     square_3_4.activated = True
     ant.grid_list = [square_0_0, square_0_1, square_3_4]
     self.assertEqual(True, ant.current_activation())
示例#6
0
 def test_ant_get_current_activation_returns_state_of_correct_square(self):
     ant = AntGrid()
     ant.x, ant.y = 3, 4
     square_0_0 = Square(x=0, y=0)
     square_0_1 = Square(x=0, y=1)
     square_3_4 = Square(x=3, y=4)
     square_3_4.activated = True
     ant.grid_list = [square_0_0, square_0_1, square_3_4]
     self.assertEqual(True, ant.current_activation())
示例#7
0
 def test_ant_get_current_activation_returns_false_at_origin(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.grid_list = [Square(x=0, y=0)]
     self.assertEqual(False, ant.current_activation())
示例#8
0
 def test_translate_decreases_x_for_dir_of_left(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.translate("left")
     self.assertEqual(-1, ant.x)
     self.assertEqual(0, ant.y)
示例#9
0
 def test_translate_increases_x_for_dir_of_right(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.translate("right")
     self.assertEqual(1, ant.x)
     self.assertEqual(0, ant.y)
示例#10
0
 def test_translate_decreases_y_for_dir_of_down(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.translate("down")
     self.assertEqual(0, ant.x)
     self.assertEqual(-1, ant.y)
示例#11
0
 def test_translate_increases_y_for_dir_of_up(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.translate("up")
     self.assertEqual(0, ant.x)
     self.assertEqual(1, ant.y)
示例#12
0
 def test_ant_get_current_activation_returns_false_at_origin(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.grid_list = [Square(x=0, y=0)]
     self.assertEqual(False, ant.current_activation())
示例#13
0
 def test_translate_decreases_x_for_dir_of_left(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.translate("left")
     self.assertEqual(-1, ant.x)
     self.assertEqual(0, ant.y)
示例#14
0
 def test_translate_increases_x_for_dir_of_right(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.translate("right")
     self.assertEqual(1, ant.x)
     self.assertEqual(0, ant.y)
示例#15
0
 def test_translate_decreases_y_for_dir_of_down(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.translate("down")
     self.assertEqual(0, ant.x)
     self.assertEqual(-1, ant.y)
示例#16
0
 def test_translate_increases_y_for_dir_of_up(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.translate("up")
     self.assertEqual(0, ant.x)
     self.assertEqual(1, ant.y)