C# Class SharpNeat.Domains.PreyCapture.PreyCaptureWorld

The prey capture task's grid world. Encapsulates agent's sensor and motor hardware and the prey's simple stochastic movement.
ファイルを表示 Open project: colgreen/sharpneat Class Usage Examples

Public Methods

Method Description
InitPositions ( ) : void

Initialise agent and prey positions. The prey is positioned randomly with at least 4 empty squares between it and a wall (in all directions). The agent is positioned randomly but such that the prey is within sensor range (distance 2 or less).

IsPreyCaptured ( ) : bool

Gets a boolean that indicates if the prey has been captured.

MoveAgent ( IBlackBox agent ) : void

Allow the agent to move one square based on its decision. Note that the agent can choose to not move.

MovePrey ( ) : void

Move the prey. The prey moves by a simple set of stochastic rules that make it more likely to move away from the agent, and more so when it is close.

PreyCaptureWorld ( int gridSize, int preyInitMoves, double preySpeed, double sensorRange, int maxTimesteps ) : System

Constructs with the provided world parameter arguments.

RunTrial ( IBlackBox agent ) : bool

Runs one trial of the provided agent in the world. Returns true if the agent captures the prey within the maximum number of timesteps allowed.

SetAgentInputsAndActivate ( IBlackBox agent ) : void

Determine the agent's position in the world relative to the prey and walls, and set its sensor inputs accordingly.

Private Methods

Method Description
CalcAngleDelta ( double a, double b ) : double

Calculates minimum angle between two vectors (specified by angle only).

MovePrey_T ( double distance ) : double

Method Details

InitPositions() public method

Initialise agent and prey positions. The prey is positioned randomly with at least 4 empty squares between it and a wall (in all directions). The agent is positioned randomly but such that the prey is within sensor range (distance 2 or less).
public InitPositions ( ) : void
return void

IsPreyCaptured() public method

Gets a boolean that indicates if the prey has been captured.
public IsPreyCaptured ( ) : bool
return bool

MoveAgent() public method

Allow the agent to move one square based on its decision. Note that the agent can choose to not move.
public MoveAgent ( IBlackBox agent ) : void
agent IBlackBox
return void

MovePrey() public method

Move the prey. The prey moves by a simple set of stochastic rules that make it more likely to move away from the agent, and more so when it is close.
public MovePrey ( ) : void
return void

PreyCaptureWorld() public method

Constructs with the provided world parameter arguments.
public PreyCaptureWorld ( int gridSize, int preyInitMoves, double preySpeed, double sensorRange, int maxTimesteps ) : System
gridSize int
preyInitMoves int
preySpeed double
sensorRange double
maxTimesteps int
return System

RunTrial() public method

Runs one trial of the provided agent in the world. Returns true if the agent captures the prey within the maximum number of timesteps allowed.
public RunTrial ( IBlackBox agent ) : bool
agent IBlackBox
return bool

SetAgentInputsAndActivate() public method

Determine the agent's position in the world relative to the prey and walls, and set its sensor inputs accordingly.
public SetAgentInputsAndActivate ( IBlackBox agent ) : void
agent IBlackBox
return void