Example #1
0
 def test_set_cell(self):
     world = [
         [
             CELL_FOOD, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
     ]
     test_world = World(WORLD_DIM, NUM_FOODS)
     test_world.grid = world
     test_world.set_cell(0, 0, CELL_EMPTY)
     self.assertEqual(test_world.get_cell(0, 0), '',
                      "Testing set_cell() method.")
     test_world.set_cell(0, 0, CELL_FOOD)
     self.assertEqual(test_world.get_cell(0, 0), 'FOOD',
                      "Testing set_cell() method.")
Example #2
0
 def test_get_cell(self):
     world = [
         [
             CELL_FOOD, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
         [
             CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY,
             CELL_EMPTY
         ],
     ]
     test_world = World(WORLD_DIM, NUM_FOODS)
     test_world.grid = world
     self.assertEqual(test_world.get_cell(0, 0), 'FOOD',
                      "Testing get_cell() method on CELL_FODD.")
     self.assertEqual(test_world.get_cell(0, 1), '',
                      "Testing get_cell() method on CELL_EMPTY")
 def test_set_cell(self):
     world = [[CELL_FOOD, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY], ]
     test_world = World(WORLD_DIM, NUM_FOODS)
     test_world.grid = world
     test_world.set_cell(0, 0, CELL_EMPTY)
     self.assertEqual(test_world.get_cell(0, 0), '', "Testing set_cell() method.")
     test_world.set_cell(0, 0, CELL_FOOD)
     self.assertEqual(test_world.get_cell(0, 0), 'FOOD', "Testing set_cell() method.")
 def test_get_cell(self):
     world = [[CELL_FOOD, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY],
              [CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY, CELL_EMPTY], ]
     test_world = World(WORLD_DIM, NUM_FOODS)
     test_world.grid = world
     self.assertEqual(test_world.get_cell(0, 0), 'FOOD', "Testing get_cell() method on CELL_FODD.")
     self.assertEqual(test_world.get_cell(0, 1), '', "Testing get_cell() method on CELL_EMPTY")