/// <summary> /// Construct with the provided task and evaluator parameters. /// </summary> /// <param name="preyInitMoves">Prey initial moves. The number of moves the prey is allowed to move before the agent can move.</param> /// <param name="preySpeed">Prey speed; in the interval [0, 1].</param> /// <param name="sensorRange">The sensor range of the agent.</param> /// <param name="maxTimesteps">The maximum number of simulation timesteps to run without the agent capturing the prey.</param> /// <param name="trialsPerEvaluation">The number of prey capture trials to run per evaluation.</param> public PreyCaptureEvaluator( int preyInitMoves, float preySpeed, float sensorRange, int maxTimesteps, int trialsPerEvaluation) { // Construct a re-usable instance of the prey capture world. _world = new PreyCaptureWorld(preyInitMoves, preySpeed, sensorRange, maxTimesteps); _trialsPerEvaluation = trialsPerEvaluation; }
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); } }
public PreyCaptureWorldBenchmark() { _world = new PreyCaptureWorld(4, 1f, 4f, 1000); _agent = new MockPreyCaptureAgent(); }