def test_energy(self):
        self.world = universe.create_world('same_vs_different', seed=0)

        self.world.agent = agents.RandomAgent(self.world)
        energy = self.world.energy
        for _ in xrange(100):
            self.world.step()
            self.assertEqual(self.world.energy, energy)
Esempio n. 2
0
    def test_energy(self):
        self.world = universe.create_world('occlusion', seed=0)

        # check that energy is conserved
        self.world.agent = agents.RandomAgent(self.world)
        energy = self.world.energy
        for _ in xrange(100):
            self.world.step()
            self.assertEqual(self.world.energy, energy)
Esempio n. 3
0
    def test_energy(self):
        self.world = universe.create_world('mazes',
                                           seed=0,
                                           method='subdivide',
                                           width=7,
                                           height=7)

        self.world.agent = agents.RandomAgent(self.world)
        energy = self.world.energy
        for _ in xrange(100):
            self.world.step()
            self.assertEqual(self.world.energy, energy)
Esempio n. 4
0
    def test_no_touching(self):
        """Check that we can take random actions and get the reward/termination we
        expect."""
        #replace the world agent with a random agent
        self.world.agent = agents.RandomAgent(self.world)

        agent = self.world.objects['agent']
        block = self.world.objects['block']

        for _ in xrange(100):
            obs, reward, done, info = self.world.step()

            #check that we got a reward if we're touching the block and not
            #otherwise
            if np.sum(utils.roundup(
                    np.abs(agent.position - block.position))) <= 1:
                self.assertEqual(reward, 999)
                self.assertTrue(done)
                break
            else:
                self.assertEqual(reward, -1)
                self.assertFalse(done)
Esempio n. 5
0
 def test_energy(self):
     self.world.agent = agents.RandomAgent(self.world)
     energy = self.world.energy
     for _ in xrange(100):
         self.world.step()
         self.assertEqual(self.world.energy, energy)
Esempio n. 6
0
 def test_energy(self):
     self.world.agent = agents.RandomAgent(self.world)
     energy = self.world.energy
     for _ in xrange(100):
         self.world.step()
         self.assertTrue(np.abs(self.world.energy - energy) < 1e-3)