* are reserved for SheepAgents (so, first possible id==10) uneven ids
* beginning from 10 are reserved for WolfAgents (so, first possible
* id==11)
*/
env[0].addCollidingAgent((obstacleAgents[0] = new ObstacleAgent(0,
env[0], params)), new Vector2D(250, -5), 0);
env[0].addCollidingAgent((obstacleAgents[1] = new ObstacleAgent(1,
env[0], params)), new Vector2D(250, 515), 0);
env[0].addCollidingAgent((obstacleAgents[2] = new ObstacleAgent(2,
env[0], params)), new Vector2D(5, 255), 90);
env[0].addCollidingAgent((obstacleAgents[0] = new ObstacleAgent(3,
env[0], params)), new Vector2D(495, 255), 90);
sheepAgents = new SheepAgent[params.getParValueInt("numberOfSheep")];
double sheepSpeed = (params.getParValueDouble("sheepSpeed"));
for (int i = 0; i < sheepAgents.length; i++) {
sheepAgents[i] = new SheepAgent(10 + 2 * i, env[0], sheepSpeed,
params.getParValueInt("numberOfDistanceSensors"), random,
0, params);
/*
* Area for deserialisation of existing NeuroBrains.
*/
// if(i==0){
// ObjectInputStream ois;
// SparseNet neuralNet = null;
// NeuroBrain neuroBrain=null;
// try {
// ois = new ObjectInputStream(new FileInputStream (new
// File("agent#" + 10 + ".jos")));
// neuralNet = (SparseNet)ois.readObject();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// }
// neuroBrain=new NeuroBrain(sheepAgents[i], random);
// neuroBrain.net = neuralNet;
// sheepAgents[i].implantBrain(neuroBrain);
// }
//
//
// else{
// sheepAgents[i].implantBrain(new NeuroBrain(sheepAgents[i],
// random));
// }
sheepAgents[i].getBrainControlledAgent().implantBrain(
new NeuroBrainChristian(sheepAgents[i], random));
boolean sheepAgentCollides = true;
Vector2D position = null;
double angle = 0.0;
do {
try {
position = getRandomVector2D(random);
angle = random.nextDouble() * 360;
if (!env[0].collides(sheepAgents[i], position, angle, null)) {
sheepAgentCollides = false;
}
} catch (Exception e) {
sheepAgentCollides = false;
}
} while (sheepAgentCollides);
env[0].addCollidingAgent(sheepAgents[i], position, angle);
}
wolfAgents = new WolfAgent[params.getParValueInt("numberOfWolf")];
double wolfSpeed = params.getParValueDouble("wolfSpeed");
double detectionRadius = params
.getParValueDouble("wolfDetectionRadius");
double catchRadius = params.getParValueDouble("wolfCatchRadius");
for (int i = 0; i < wolfAgents.length; i++) {
wolfAgents[i] = new WolfAgent(10 + 2 * i + 1, env[0], wolfSpeed,
defaultNumberOfWolfDistanceSensors, detectionRadius,
catchRadius, random, params);
boolean wolfAgentCollides = true;
Vector2D position = null;
double angle = 0.0;
do {
position = getRandomVector2D(random);
angle = random.nextDouble() * 360;
if (!env[0].collides(wolfAgents[i], position, angle, null)) {