/*
* File name: TEMPScheduler.java (package eas.simulation.spatial.sim2D.standardEnvironments)
* Author(s): Lukas König
* Java version: 6.0
* Generation date: 14.02.2011 (22:17:39)
*
* (c) This file and the EAS (Easy Agent Simulation) framework containing it
* is protected by Creative Commons by-nc-sa license. Any altered or
* further developed versions of this file have to meet the agreements
* stated by the license conditions.
*
* In a nutshell
* -------------
* You are free:
* - to Share -- to copy, distribute and transmit the work
* - to Remix -- to adapt the work
*
* Under the following conditions:
* - Attribution -- You must attribute the work in the manner specified by the
* author or licensor (but not in any way that suggests that they endorse
* you or your use of the work).
* - Noncommercial -- You may not use this work for commercial purposes.
* - Share Alike -- If you alter, transform, or build upon this work, you may
* distribute the resulting work only under the same or a similar license to
* this one.
*
* + Detailed license conditions (Germany):
* http://creativecommons.org/licenses/by-nc-sa/3.0/de/
* + Detailed license conditions (unported):
* http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en
*
* This header must be placed in the beginning of any version of this file.
*/
package eas.simulation.spatial.sim2D.standardEnvironments;
import java.util.Random;
import eas.math.geometry.Vector2D;
import eas.plugins.PluginProperties;
import eas.plugins.masterScheduler.AbstractDefaultMaster;
import eas.simulation.agent.AbstractAgent;
import eas.simulation.spatial.sim2D.standardAgents.AbstractAgent2D;
import eas.simulation.spatial.sim2D.standardAgents.ObstacleAgent;
import eas.simulation.spatial.sim2D.standardAgents.jasmine.JasmineRobot;
import eas.simulation.spatial.standardBrains.marb.MARBBrain;
import eas.startSetup.ParCollection;
/**
* @author Lukas König
*
*/
@PluginProperties(pluginIsHidden = true)
public class TestSchedulerFast extends AbstractDefaultMaster<AbstractEnvironment2D<AbstractAgent2D<?>>> {
private static final long serialVersionUID = -932517514945554127L;
@SuppressWarnings("unchecked")
@Override
public AbstractEnvironment2D<AbstractAgent2D<?>>[] generateRunnables(ParCollection params) {
@SuppressWarnings({ "rawtypes" })
AbstractEnvironment2DFast<AbstractAgent2D> env = new AbstractEnvironment2DFast(0, params) {
/**
*
*/
private static final long serialVersionUID = -5942918193646510033L;};
Random rand = new Random(params.getSeed());
JasmineRobot agent;
Vector2D pos;
double richt;
env.addCollidingAgent(
new ObstacleAgent(0, env, params),
new Vector2D(0, -1000),
0,
new Vector2D(10, 1));
env.addCollidingAgent(
new ObstacleAgent(1, env, params),
new Vector2D(0, 1000),
0,
new Vector2D(10, 1));
env.addCollidingAgent(
new ObstacleAgent(2, env, params),
new Vector2D(-2500, 0),
90,
new Vector2D(3.95, 1));
env.addCollidingAgent(
new ObstacleAgent(3, env, params),
new Vector2D(2500, 0),
90,
new Vector2D(3.95, 1));
for (int j = 4; j <= 500; j++) {
richt = rand.nextDouble() * 360;
agent = new JasmineRobot(j, env, rand, params, false, 0);
agent.deactivateEvolution();
// BRAIN.
agent.implantBrain(new MARBBrain<AbstractAgent<?>>(agent, "002, 003, 001, 001, 000, 012, 001, 010, 000, 005, 000, 000, 001, 001, 000, 000, 000, 001, 004, 001, 001, 000, 000, 000", params));
// ADDITIONAL SENSOR.
// agent.addSensor(new GenericSensor<Set<Integer>, AbstractEnvironment2D<AbstractAgent2D<?>>, JasmineRobot>() {
//
// @Override
// public Set<Integer> sense(AbstractEnvironment2D<AbstractAgent2D<?>> env,
// JasmineRobot agent) {
// return env.getAgentsTouchingTilesFromAll(env.getTilesTouchingAgent(agent.id()));
// }
//
// @Override
// public String id() {
// return "AgentsInSameTile";
// }
// });
pos = new Vector2D(
rand.nextDouble() * ((env.getBoundingBox(false).lowerRightCorner().x - env.getBoundingBox(false).upperLeftCorner().x) / 1.1) + env.getBoundingBox(false).upperLeftCorner().x / 1.1,
rand.nextDouble() * ((env.getBoundingBox(false).lowerRightCorner().y - env.getBoundingBox(false).upperLeftCorner().y) / 1.1) + env.getBoundingBox(false).upperLeftCorner().y / 1.1);
while (!env.addCollidingAgent(agent, pos, richt)) {
pos = new Vector2D(
rand.nextDouble() * ((env.getBoundingBox(false).lowerRightCorner().x - env.getBoundingBox(false).upperLeftCorner().x) / 1.1) + env.getBoundingBox(false).upperLeftCorner().x / 1.1,
rand.nextDouble() * ((env.getBoundingBox(false).lowerRightCorner().y - env.getBoundingBox(false).upperLeftCorner().y)) / 1.1 + env.getBoundingBox(false).upperLeftCorner().y / 1.1);
}
}
return new AbstractEnvironment2D[] {env};
}
@Override
public String id() {
return "TEMP";
}
// @Override
// public synchronized void runDuringSim(AbstractEnvironment2D env,
// Wink simZyk, ParCollection params) {
// System.out.println();
// System.out.println(env.setAgentPosition(5, new Vector2D(env.getAgentPosition(4))));
//
// }
}