/*
* File name: MutationLessScheduler.java (package eas.simulation.users.lukas.marbImplicitEvolution.gateWithoutMutation)
* Author(s): Lukas König
* Java version: 6.0
* Generation date: 01.04.2011 (10:57:53)
*
* (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.users.lukas.marbImplicitEvolution.movingFitnessNoMutation;
import java.util.List;
import java.util.Random;
import eas.math.geometry.Rectangle2D;
import eas.math.geometry.Vector2D;
import eas.plugins.masterScheduler.AbstractDefaultMaster;
import eas.simulation.ConstantsSimulation;
import eas.simulation.spatial.sim2D.standardAgents.AbstractAgent2D;
import eas.simulation.spatial.standardBrains.marb.MARBBrain;
import eas.startSetup.ParCollection;
import eas.startSetup.SingleParameter;
import eas.startSetup.parameterDatatypes.Datatypes;
import eas.users.lukas.marbImplicitEvolution.simpleMazeEnvironment.MARBFastEnvironment;
/**
* @author Lukas König
*
*/
public class MutationLessSchedulerRegularSelection extends AbstractDefaultMaster<MARBFastEnvironment> {
/**
*
*/
private static final long serialVersionUID = -8126196332565852174L;
@Override
public MARBFastEnvironment[] generateRunnables(ParCollection params) {
int numGoodAgents = (int) params.getParValueVector2D("NumberOfAgents").x;
int numBadAgents = (int) params.getParValueVector2D("NumberOfAgents").y;
MARBFastEnvironment env = new MARBFastEnvironment(0, params, false);
JasmineRobotWithoutMutationRegularSelection agent;
MARBBrain<AbstractAgent2D<?>> brain;
Random rand = new Random(params.getSeed());
String gutesGenom = "001, 003, 003, 001, 000, 012, 004, 196, 000, 015, 000, 012, 007, 135, 000, 006, 000, 010, 000, 000, 001, 001, 000, 012, 001, 191, 000, 004, 000, 012, 001, 032, 000, 005, 000, 012, 003, 073, 000, 015, 000, 011, 000, 012, 004, 170, 000, 016, 000, 010, 000, 010, 000, 000, 005, 001, 000, 012, 004, 000, 012, 007, 000, 015, 000, 012, 001, 073, 000, 008, 000, 011, 000, 000, 011, 001, 000, 000, 000, 015, 003, 003, 001, 000, 000, 000, 011, 004, 001, 001, 000, 012, 006, 031, 000, 008, 000, 000, 022, 001, 000, 000, 000, 026, 003, 005, 001, 000, 000, 000, 010, 002, 005, 001, 000, 000, 000, 009, 003, 004, 001, 000, 012, 006, 108, 000, 009, 000, 012, 004, 140, 000, 016, 000, 010, 000, 012, 006, 125, 000, 008, 000, 011, 000, 000, 010, 001, 000, 012, 001, 092, 000, 016, 000, 012, 003, 113, 000, 016, 000, 012, 001, 017, 000, 015, 000, 012, 003, 000, 012, 001, 000, 008, 000, 011, 000, 010, 000, 010, 000, 000, 006, 001, 000, 012, 001, 163, 000, 009, 000, 012, 003, 000, 012, 001, 000, 015, 000, 010, 000, 000, 015, 001, 000, 012, 002, 013, 000, 016, 000, 012, 005, 091, 000, 006, 000, 010, 000, 000, 011, 001, 000, 000, 000, 022, 004, 005, 001, 000, 012, 003, 140, 000, 009, 000, 012, 007, 098, 000, 009, 000, 010, 000, 012, 001, 071, 000, 008, 000, 012, 007, 210, 000, 008, 000, 011, 000, 010, 000, 000, 015, 001, 000, 000, 000, 006, 005, 003, 001, 000, 012, 006, 045, 000, 015, 000, 000, 011, 001, 000, 000, 000, 005, 005, 009, 001, 000, 012, 006, 158, 000, 015, 000, 012, 006, 132, 000, 009, 000, 012, 004, 080, 000, 009, 000, 012, 002, 000, 012, 005, 000, 016, 000, 010, 000, 011, 000, 011, 000, 000, 006, 001, 000, 012, 003, 247, 000, 008, 000, 012, 004, 089, 000, 008, 000, 011, 000, 000, 009, 001, 000, 012, 005, 253, 000, 016, 000, 000, 004, 001, 000, 012, 005, 095, 000, 009, 000, 012, 006, 045, 000, 009, 000, 010, 000, 000, 019, 001, 000, 012, 005, 081, 000, 015, 000, 012, 005, 213, 000, 009, 000, 010, 000, 000, 026, 001, 000, 012, 007, 000, 012, 005, 000, 015, 000, 000, 011, 001, 000, 000, 000, 004, 005, 003, 001, 000, 000, 000, 019, 005, 001, 001, 000, 012, 007, 000, 012, 002, 000, 015, 000, 000, 002, 001, 000, 000, 000, 002, 005, 004, 001, 000, 012, 006, 143, 000, 008, 000, 012, 007, 199, 000, 015, 000, 011, 000, 000, 002, 001, 000, 000, 000";
String schlechtesGenom = "001, 003, 001, 001, 000, 013, 000, 000, 002, 001, 000, 000, 000, 002, 004, 001, 001, 000, 000, 000";
Vector2D pos;
double richt;
if (numGoodAgents < 1) {
numGoodAgents = 1;
}
if (numBadAgents < 1) {
numBadAgents = 1;
}
Rectangle2D bound = new Rectangle2D(env.getBoundingBox(false));
double puffer = 100;
bound.setLeft(bound.upperLeftCorner().x + puffer);
bound.setRight(bound.lowerRightCorner().x - puffer);
bound.setTop(bound.upperLeftCorner().y + puffer);
bound.setBottom(bound.lowerRightCorner().y - puffer);
for (int j = 0; j < numGoodAgents; j++) {
agent = new JasmineRobotWithoutMutationRegularSelection(
j,
env,
rand,
params,
true,
360,
gutesGenom,
schlechtesGenom);
brain = new MARBBrain<AbstractAgent2D<?>>(
agent,
gutesGenom,
params);
agent.implantBrain(brain);
pos = new Vector2D(
rand.nextDouble() * (bound.lowerRightCorner().x - bound.upperLeftCorner().x) + bound.upperLeftCorner().x,
rand.nextDouble() * (bound.lowerRightCorner().y - bound.upperLeftCorner().y) + bound.upperLeftCorner().y);
richt = rand.nextDouble() * 360;
while (!env.addCollidingAgent(
agent,
pos, richt)) {
pos = new Vector2D(
rand.nextDouble() * (bound.lowerRightCorner().x - bound.upperLeftCorner().x) + bound.upperLeftCorner().x,
rand.nextDouble() * (bound.lowerRightCorner().y - bound.upperLeftCorner().y) + bound.upperLeftCorner().y);
}
}
for (int j = 0; j < numBadAgents; j++) {
agent = new JasmineRobotWithoutMutationRegularSelection(
j,
env,
rand,
params,
true,
360,
gutesGenom,
schlechtesGenom);
brain = new MARBBrain<AbstractAgent2D<?>>(
agent,
schlechtesGenom,
params);
agent.implantBrain(brain);
pos = new Vector2D(
rand.nextDouble() * (bound.lowerRightCorner().x - bound.upperLeftCorner().x) + bound.upperLeftCorner().x,
rand.nextDouble() * (bound.lowerRightCorner().y - bound.upperLeftCorner().y) + bound.upperLeftCorner().y);
richt = rand.nextDouble() * 360;
while (!env.addCollidingAgent(
agent,
pos, richt)) {
pos = new Vector2D(
rand.nextDouble() * (bound.lowerRightCorner().x - bound.upperLeftCorner().x) + bound.upperLeftCorner().x,
rand.nextDouble() * (bound.lowerRightCorner().y - bound.upperLeftCorner().y) + bound.upperLeftCorner().y);
}
}
env.getJasmineAgents();
return new MARBFastEnvironment[] { env };
}
@Override
public List<SingleParameter> getParameters() {
List<SingleParameter> list = super.getParameters();
list.add(new SingleParameter("NumberOfAgents", Datatypes.VECTOR2D, new Vector2D(20, 20), "Number of (good, bad) Agents.", this.id().toUpperCase()));
return list;
}
@Override
public String id() {
return ConstantsSimulation.DEFAULT_MASTER_SCHEDULER_ID + "-mutationslessSchedulerRegularSelection";
}
}