Пример #1
0
  def testDistanceToBoundaries(self):
    universe = OneDUniverse(debugSensor=True, debugMotor=True,
                            nSensor=100, wSensor=5,
                            nMotor=25, wMotor=5)
    world = OneDWorld(universe, [2, 0, 5, 15, 10], 2)
    self.assertEqual(world.distanceToBoundaries(), (2, 2))

    world.move(-2)
    self.assertEqual(world.distanceToBoundaries(), (0, 4))

    world.move(2)
    world.move(2)
    self.assertEqual(world.distanceToBoundaries(), (4, 0))
Пример #2
0
    def testChooseMotorValue(self):
        universe = OneDUniverse(nSensor=100, wSensor=5, nMotor=105, wMotor=5)
        world = OneDWorld(universe, [2, 0, 5, 15, 10], 2)
        agent = RandomOneDAgent(world,
                                possibleMotorValues=set(xrange(-10, 10)))

        for _ in range(100):
            motorValue = agent.chooseMotorValue()
            self.assertTrue(-2 <= motorValue <= 2)  # bounded by size of world

        world.move(-2)

        for _ in range(100):
            motorValue = agent.chooseMotorValue()
            self.assertTrue(0 <= motorValue <= 4)  # bounded by size of world
  def testChooseMotorValue(self):
    universe = OneDUniverse(nSensor=100, wSensor=5,
                            nMotor=105, wMotor=5)
    world = OneDWorld(universe, [2, 0, 5, 15, 10], 2)
    agent = RandomOneDAgent(world, possibleMotorValues=set(xrange(-10, 10)))

    for _ in range(100):
      motorValue = agent.chooseMotorValue()
      self.assertTrue(-2 <= motorValue <= 2)  # bounded by size of world

    world.move(-2)

    for _ in range(100):
      motorValue = agent.chooseMotorValue()
      self.assertTrue(0 <= motorValue <= 4)  # bounded by size of world
Пример #4
0
    def testDistanceToBoundaries(self):
        universe = OneDUniverse(debugSensor=True,
                                debugMotor=True,
                                nSensor=100,
                                wSensor=5,
                                nMotor=25,
                                wMotor=5)
        world = OneDWorld(universe, [2, 0, 5, 15, 10], 2)
        self.assertEqual(world.distanceToBoundaries(), (2, 2))

        world.move(-2)
        self.assertEqual(world.distanceToBoundaries(), (0, 4))

        world.move(2)
        world.move(2)
        self.assertEqual(world.distanceToBoundaries(), (4, 0))
Пример #5
0
  def testMotion(self):
    universe = OneDUniverse(debugSensor=True, debugMotor=True,
                            nSensor=100, wSensor=5,
                            nMotor=100, wMotor=20)
    world = OneDWorld(universe, [2, 0, 5, 15, 10], 2)

    self.assertEqual(set(xrange(25, 30)), world.sense())

    self.assertEqual(world.move(1), set(xrange(60, 80)))
    self.assertEqual(set(xrange(75, 80)), world.sense())

    self.assertEqual(world.move(-2), set(xrange(0, 20)))
    self.assertEqual(set(xrange(0, 5)), world.sense())

    self.assertEqual(world.move(0), set(xrange(40, 60)))
    self.assertEqual(set(xrange(0, 5)), world.sense())
Пример #6
0
    def testMotion(self):
        universe = OneDUniverse(debugSensor=True,
                                debugMotor=True,
                                nSensor=100,
                                wSensor=5,
                                nMotor=100,
                                wMotor=20)
        world = OneDWorld(universe, [2, 0, 5, 15, 10], 2)

        self.assertEqual(set(xrange(25, 30)), world.sense())

        self.assertEqual(world.move(1), set(xrange(60, 80)))
        self.assertEqual(set(xrange(75, 80)), world.sense())

        self.assertEqual(world.move(-2), set(xrange(0, 20)))
        self.assertEqual(set(xrange(0, 5)), world.sense())

        self.assertEqual(world.move(0), set(xrange(40, 60)))
        self.assertEqual(set(xrange(0, 5)), world.sense())