예제 #1
0
    public void MoveAgent()
    {
        var world = new PreyCaptureWorld(4, 1f, 4f, 100);
        var agent = new MockPreyCaptureAgent();

        // Agent moving north test.
        {
            world.InitPositions();
            Int32Point posBefore = world.AgentPosition;
            var        outputs   = agent.Outputs.Span;
            outputs.Clear();
            outputs[0] = 1.0;
            world.MoveAgent(agent);
            Int32Point posDelta = world.AgentPosition - posBefore;
            Assert.Equal(new Int32Point(0, 1), posDelta);
        }

        // Agent moving east test.
        {
            world.InitPositions();
            Int32Point posBefore = world.AgentPosition;
            var        outputs   = agent.Outputs.Span;
            outputs.Clear();
            outputs[1] = 1.0;
            world.MoveAgent(agent);
            Int32Point posDelta = world.AgentPosition - posBefore;
            Assert.Equal(new Int32Point(1, 0), posDelta);
        }

        // Agent moving south test.
        {
            world.InitPositions();
            Int32Point posBefore = world.AgentPosition;
            var        outputs   = agent.Outputs.Span;
            outputs.Clear();
            outputs[2] = 1.0;
            world.MoveAgent(agent);
            Int32Point posDelta = world.AgentPosition - posBefore;
            Assert.Equal(new Int32Point(0, -1), posDelta);
        }

        // Agent moving west test.
        {
            world.InitPositions();
            Int32Point posBefore = world.AgentPosition;
            var        outputs   = agent.Outputs.Span;
            outputs.Clear();
            outputs[3] = 1.0;
            world.MoveAgent(agent);
            Int32Point posDelta = world.AgentPosition - posBefore;
            Assert.Equal(new Int32Point(-1, 0), posDelta);
        }
    }
예제 #2
0
 public PreyCaptureWorldBenchmark()
 {
     _world = new PreyCaptureWorld(4, 1f, 4f, 1000);
     _agent = new MockPreyCaptureAgent();
 }