示例#1
0
    def test_agent_is_at_treasure(self):
        world = GridWorld(10, 10)
        world.add_agent(Agent(0, 0))
        world.add_object(Treasure(8, 8))

        self.assertFalse(world.agent.is_at_any_object(world.get_objects_by_type(Treasure)))

        world.agent.x = 8
        world.agent.y = 8

        self.assertTrue(world.agent.is_at_any_object(world.get_objects_by_type(Treasure)))
示例#2
0
    def test_add_treasure(self):
        world = GridWorld(10, 10)
        world.add_object(Treasure(8, 8))

        self.assertEqual(1, len(world.get_objects()))
        self.assertListEqual([Treasure], world.get_object_types())
        self.assertEqual(1, len(world.get_objects_by_type(Treasure)))
示例#3
0
    def test_add_agent(self):
        world = GridWorld(10, 10)
        world.add_agent(Agent(0, 0))

        self.assertEqual(0, world.agent.x)
        self.assertEqual(0, world.agent.y)

        self.assertEqual(1, len(world.get_objects()))
        self.assertListEqual([Agent], world.get_object_types())
        self.assertEqual(1, len(world.get_objects_by_type(Agent)))