I'm trying to add diferent Parcel
objects at the same position. My code looks like this, where Rock
extends Parcel
:
Point origin = null;
Rock rock = null;
for (int i = 0; i < ROCKS; i++) {
if (i % 10 == 0) {
origin = model.getRandomUnoccupiedPosition(sim.getRandomGenerator());
rock = new Rock(origin, destination);
sim.register(rock);
} else {
Rock r = new Rock(origin, destination);
model.addObjectAtSamePosition(r, rock);
}
}
but after a few iterations, I get this error when trying to pick up the Rock
with a Vehicle
:
Exception in thread "Thread-1" java.lang.IllegalArgumentException: Parcel must be registered and must be either ANNOUNCED or AVAILABE, it is: null. Parcel: [Parcel-103f852].
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:146)
at com.github.rinde.rinsim.core.model.pdp.DefaultPDPModel.pickup(DefaultPDPModel.java:175)
at me.alexrs.mas.roveragent.RoverAgent.tickImpl(RoverAgent.java:105)
at com.github.rinde.rinsim.core.model.pdp.Vehicle.tick(Vehicle.java:55)
at com.github.rinde.rinsim.core.model.time.TimeModel.tickImpl(TimeModel.java:139)
at com.github.rinde.rinsim.core.model.time.SimulatedTimeModel.doStart(SimulatedTimeModel.java:32)
at com.github.rinde.rinsim.core.model.time.TimeModel.start(TimeModel.java:94)
at com.github.rinde.rinsim.ui.SimulationViewer$5.run(SimulationViewer.java:399)
The only Rock
that is registered is the one that has been registered in the Simulator
, but if I try to register more than one Rock
, I get an exception saying that two objects can't be at the same position.