...
 
Commits (2)
import davis.core.agents.rendez_vous.RDVRingAgent;
import davis.core.agents.rendez_vous.RDVRectangularAgent;
import davis.core.model.RectangularAgent;
import java.util.ArrayList;
import java.util.Random;
public class RandomWalkWaitRing extends RDVRingAgent {
public class RandomWalkPath extends RDVRectangularAgent {
Random random;
public void init() {
......@@ -11,10 +13,10 @@ public class RandomWalkWaitRing extends RDVRingAgent {
}
public void randomWalk(Object Board) {
if (random.nextBoolean()) stay();
else {
if (random.nextBoolean()) goLeft();
else goRight();
if (random.nextBoolean()) {
if (!goRight()) goLeft();
} else {
if (!goLeft()) goRight();
}
}
}
......@@ -2,7 +2,7 @@ import davis.core.agents.rendez_vous.RDVRingAgent;
import java.util.Random;
public class randomWalkRing extends RDVRingAgent {
public class RandomWalkRing extends RDVRingAgent {
Random random;
public void init() {
......@@ -14,8 +14,4 @@ public class randomWalkRing extends RDVRingAgent {
if (random.nextBoolean()) goLeft();
else goRight();
}
public void rdv(Object board) {
super.rdv(board);
}
}
import davis.core.idscheme.IdScheme;
import davis.core.model.RectangularAgent;
import davis.core.model.RectangularPlace;
import davis.core.network.AgentFactory;
import davis.core.network.RectangularGridGenerator;
import io.jbotsim.core.Topology;
public class RectangularTwoAgents<B> extends RectangularGridGenerator<RectangularPlace<B>> {
@Override
public void generate(Topology topo, IdScheme id) {
Class defaultNode = topo.getDefaultNodeModel();
topo.setDefaultNodeModel(RectangularPlace.class);
super.generate(topo, id);
topo.setDefaultNodeModel(defaultNode);
AgentFactory.<RectangularAgent<B>, B>nAgentsAtRandomPlace(topo, 2);
}
}
test1 RingAnon2AgentsSym.java RandomIds 18 randomWalkRing.java
test2 RingAnon2AgentsSym.java RandomIds 18 RandomWalkWaitRing.java
RandomWalkRing RingAnon2AgentsSym.java RandomIds 18 RandomWalkRing.java
RandomWalkPath RectangularTwoAgents.java RandomIds 18*1 RandomWalkPath.java