@Override
public void runDuringSimulation(
final EnvironmentEA env,
final Wink simZyk,
final ParCollection params) {
EnvironmentEA umg = env;
if (this.waende == null) {
this.waende = new LinkedList<Integer>();
this.drehen = new LinkedList<Boolean>();
this.versch = new LinkedList<Boolean>();
this.verzerr = new LinkedList<Boolean>();
this.winkel = new LinkedList<Double>();
this.xRicht = new LinkedList<Double>();
this.yRicht = new LinkedList<Double>();
for (int i = 0; i < umg.getDynWaende().length; i++) {
if (umg.getDynWaende()[i] != null) {
this.waende.add(i);
this.drehen.add(true);
this.versch.add(true);
this.verzerr.add(true);
this.winkel.add(this.random.nextDouble() * 0.25);
this.xRicht.add(this.random.nextDouble() * 0.25);
this.yRicht.add(this.random.nextDouble() * 0.25);
}
}
}
for (int i = 0; i < this.waende.size(); i++) {
if (this.drehen.get(i)) {
if (null != umg.dreheWand(
this.waende.get(i),
umg.getDynDrehWinkel()[this.waende.get(i)]
* 180 / Math.PI
+ this.winkel.get(i))) {
this.drehen.set(i, !this.drehen.get(i));
this.winkel.set(i, this.random.nextDouble() * 0.25);
}
} else {
if (null != umg.dreheWand(
this.waende.get(i),
umg.getDynDrehWinkel()[this.waende.get(i)]
* 180 / Math.PI
- this.winkel.get(i))) {
this.drehen.set(i, !this.drehen.get(i));
this.winkel.set(i, this.random.nextDouble() * 0.25);
}
}
if (this.versch.get(i)) {
Vector2D vSchiebg = umg.getDynVersch()[this.waende.get(i)];
vSchiebg.translate(new Vector2D(
this.xRicht.get(i),
this.yRicht.get(i)));
if (null != umg.verschWand(
this.waende.get(i),
vSchiebg)) {
this.versch.set(i, !this.versch.get(i));
this.xRicht.set(i, this.random.nextDouble() * 0.25);
this.yRicht.set(i, this.random.nextDouble() * 0.25);
}
} else {
Vector2D vSchiebg = umg.getDynVersch()[this.waende.get(i)];
vSchiebg.translate(new Vector2D(
-this.xRicht.get(i),
-this.yRicht.get(i)));
if (null != umg.verschWand(
this.waende.get(i),
vSchiebg)) {
this.versch.set(i, !this.versch.get(i));
this.xRicht.set(i, this.random.nextDouble() * 0.25);
this.yRicht.set(i, this.random.nextDouble() * 0.25);