Esempio n. 1
0
    def test_values_2(self):
        expected = [[0.06666, 0.06666, 0.06666], [0.06666, 0.26666, 0.26666],
                    [0.06666, 0.06666, 0.06666]]

        colors = [[G, G, G], [G, R, R], [G, G, G]]

        robot = Robot(world=colors)
        robot.sensor = 0.8
        robot.movement = 1.0
        actual = robot.localize(measurements=[R], motions=[[0, 0]])
        self.assertAlmostEqual(expected, actual, places=4)
Esempio n. 2
0
 def test_values_1(self):
     expected = [[0.0, 0.0, 0.0],
                 [0.0, 0.5, 0.5],
                 [0.0, 0.0, 0.0]]
     colors=[[G, G, G],
             [G, R, R],
             [G, G, G]]
     
     robot = Robot(world=colors)
     robot.sensor = 1.0
     robot.movement = 1.0
     p = robot._p(len(colors), len(colors[0]))
     actual = robot.localize(p=p, measurements=[R], motions=[[0, 0]])
     self.assertAlmostEqual(expected, actual)
Esempio n. 3
0
 def test_values_2(self):
     expected = [[0.06666, 0.06666, 0.06666],
                 [0.06666, 0.26666, 0.26666],
                 [0.06666, 0.06666, 0.06666]]
     
     colors=[[G, G, G],
             [G, R, R],
             [G, G, G]]
     
     robot = Robot(world=colors)
     robot.sensor = 0.8
     robot.movement = 1.0
     actual = robot.localize(measurements=[R], motions=[[0, 0]])
     self.assertAlmostEqual(expected, actual, places=4)
Esempio n. 4
0
    def test_values_3(self):
        expected = [[0.03333, 0.03333, 0.03333],
                    [0.13333, 0.13333, 0.53333],
                    [0.03333, 0.03333, 0.03333]]

        colors = [[G, G, G],
                  [G, R, R],
                  [G, G, G]]
        
        robot = Robot(world=colors)
        robot.sensor = 0.8
        robot.movement = 1.0
        p = robot._p(len(colors), len(colors[0]))
        actual = robot.localize(p=p, 
                                measurements=[R, R], 
                                motions=[[0, 0], [0, 1]])
        self.assertAlmostEqual(expected, actual, places=4)
Esempio n. 5
0
    def test_values_5(self):
        expected = [[0.02898, 0.02898, 0.02898],
                    [0.07246, 0.28985, 0.46376],
                    [0.02898, 0.02898, 0.02898]]

        colors = [[G, G, G],
                  [G, R, R],
                  [G, G, G]]
        
        robot = Robot(world=colors)
        robot.sensor = 0.8
        robot.movement = 0.5
        p = robot._p(len(colors), len(colors[0]))
        actual = robot.localize(p=p, 
                                measurements=[R, R], 
                                motions=[[0, 0], [0, 1]])
        self.assertAlmostEqual(expected, actual, places=4)
Esempio n. 6
0
    def test_values_7(self):
        expected = [[0.01105, 0.02464, 0.06799, 0.04472, 0.024651],
                    [0.00715, 0.01017, 0.08696, 0.07988, 0.00935],
                    [0.00739, 0.00894, 0.11272, 0.35350, 0.04065],
                    [0.00910, 0.00715, 0.01434, 0.04313, 0.03642]]

        colors = [[R, G, G, R,R],
                  [R, R, G, R, R],
                  [R, R, G, G, R],
                  [R, R, R, R, R]]
        
        robot = Robot(world=colors)
        robot.sensor = 0.7
        robot.movement = 0.8
        p = robot._p(len(colors), len(colors[0]))
        actual = robot.localize(p=p, 
                                measurements=[G, G, G, 
                                              G, G], 
                                motions=[[0, 0], [0, 1], [1, 0], [1, 0], 
                                         [0, 1]])
        self.assertAlmostEqual(expected, actual, places=4)
Esempio n. 7
0
    def test_values_1(self):
        expected = [[0.0, 0.0, 0.0], [0.0, 0.5, 0.5], [0.0, 0.0, 0.0]]
        colors = [[G, G, G], [G, R, R], [G, G, G]]

        robot = Robot(world=colors)
        robot.sensor = 1.0
        robot.movement = 1.0
        p = robot._p(len(colors), len(colors[0]))
        actual = robot.localize(p=p, measurements=[R], motions=[[0, 0]])
        self.assertAlmostEqual(expected, actual)
Esempio n. 8
0
    def test_values_5(self):
        expected = [[0.02898, 0.02898, 0.02898], [0.07246, 0.28985, 0.46376],
                    [0.02898, 0.02898, 0.02898]]

        colors = [[G, G, G], [G, R, R], [G, G, G]]

        robot = Robot(world=colors)
        robot.sensor = 0.8
        robot.movement = 0.5
        p = robot._p(len(colors), len(colors[0]))
        actual = robot.localize(p=p,
                                measurements=[R, R],
                                motions=[[0, 0], [0, 1]])
        self.assertAlmostEqual(expected, actual, places=4)
Esempio n. 9
0
    def test_values_3(self):
        expected = [[0.03333, 0.03333, 0.03333], [0.13333, 0.13333, 0.53333],
                    [0.03333, 0.03333, 0.03333]]

        colors = [[G, G, G], [G, R, R], [G, G, G]]

        robot = Robot(world=colors)
        robot.sensor = 0.8
        robot.movement = 1.0
        p = robot._p(len(colors), len(colors[0]))
        actual = robot.localize(p=p,
                                measurements=[R, R],
                                motions=[[0, 0], [0, 1]])
        self.assertAlmostEqual(expected, actual, places=4)
Esempio n. 10
0
    def test_values_7(self):
        expected = [[0.01105, 0.02464, 0.06799, 0.04472, 0.024651],
                    [0.00715, 0.01017, 0.08696, 0.07988, 0.00935],
                    [0.00739, 0.00894, 0.11272, 0.35350, 0.04065],
                    [0.00910, 0.00715, 0.01434, 0.04313, 0.03642]]

        colors = [[R, G, G, R, R], [R, R, G, R, R], [R, R, G, G, R],
                  [R, R, R, R, R]]

        robot = Robot(world=colors)
        robot.sensor = 0.7
        robot.movement = 0.8
        p = robot._p(len(colors), len(colors[0]))
        actual = robot.localize(p=p,
                                measurements=[G, G, G, G, G],
                                motions=[[0, 0], [0, 1], [1, 0], [1, 0],
                                         [0, 1]])
        self.assertAlmostEqual(expected, actual, places=4)
Esempio n. 11
0
 def test_move_up(self):
     bot = Robot(world=self.world)
     self.assertEqual([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0]],
                      bot.move(self.world, [-1, 0]))
Esempio n. 12
0
 def test_move_up_left(self):
     bot = Robot(world=self.world)
     self.assertEqual([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],
                      bot.move(self.world, [-1, -1]))
Esempio n. 13
0
 def test_move_down_right(self):
     bot = Robot(world=self.world)
     self.assertEqual([[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0]],
                      bot.move(self.world, [1, 1]))
Esempio n. 14
0
 def test_multiple_motions(self):
     bot = Robot(world=self.world)
     self.assertEqual(self.world, 
                      bot.move(self.world, 
                               [[1, 0], [0, 1], [-1, 0], [0, -1]]))
Esempio n. 15
0
 def test_move_down_right(self):
     bot = Robot(world=self.world)
     self.assertEqual([[0, 0, 0, 0, 0],
                       [0, 1, 0, 0, 0],
                       [0, 0, 0, 0, 0]], 
                      bot.move(self.world, [1, 1]))
Esempio n. 16
0
 def test_move_up_left(self):
     bot = Robot(world=self.world)
     self.assertEqual([[0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 1]], 
                      bot.move(self.world, [-1, -1]))
Esempio n. 17
0
 def test_move_up(self):
     bot = Robot(world=self.world)
     self.assertEqual([[0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0],
                       [1, 0, 0, 0, 0]], 
                      bot.move(self.world, [-1, 0]))
Esempio n. 18
0
 def test_stand_still(self):
     bot = Robot(world=self.world)
     self.assertEqual([[1, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0]],
                      bot.move(self.world, [0, 0]))
Esempio n. 19
0
 def test_stand_still(self):
     bot = Robot(world=self.world)
     self.assertEqual([[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],
                      bot.move(self.world, [0, 0]))
Esempio n. 20
0
 def test_multiple_motions(self):
     bot = Robot(world=self.world)
     self.assertEqual(
         self.world, bot.move(self.world,
                              [[1, 0], [0, 1], [-1, 0], [0, -1]]))