Is Greenfoot not able to handle many actors?
50% of the time my scenario has more then 40 actors and multiple actors have to be removed at the same time I will get errors. Maybe greenfoot multi-threading issue?
Mostly:
java.lang.ArithmeticException: / by zero
at greenfoot.ActorSet.resizeHashmap(ActorSet.java:87)
at greenfoot.ActorSet.remove(ActorSet.java:174)
at greenfoot.ActorSet.remove(ActorSet.java:149)
at greenfoot.TreeActorSet.remove(TreeActorSet.java:185)
at greenfoot.World.removeObject(World.java:458)
Exception in thread "Timer-2" java.lang.ArrayIndexOutOfBoundsException: Index 10 out of bounds for length 9
at greenfoot.ActorSet.resizeHashmap(ActorSet.java:88)
at greenfoot.ActorSet.add(ActorSet.java:68)
at greenfoot.TreeActorSet.add(TreeActorSet.java:180)
at greenfoot.World.addObject(World.java:430)
java.lang.StackOverflowError
at greenfoot.collision.ibsp.BSPNode.containsActor(BSPNode.java:205)
at greenfoot.collision.ibsp.IBSPColChecker.insertObject(IBSPColChecker.java:220)
at greenfoot.collision.ibsp.IBSPColChecker.insertObject(IBSPColChecker.java:257)
java.lang.NullPointerException
at greenfoot.World.getObjectsAtPixel(World.java:771)
at greenfoot.WorldVisitor.getObjectsAtPixel(WorldVisitor.java:72)
at greenfoot.core.WorldHandler.getObject(WorldHandler.java:244)
at greenfoot.core.WorldHandler$3.getTopMostActorAt(WorldHandler.java:393)
at greenfoot.gui.input.mouse.MouseEventData.setActors(MouseEventData.java:315)
at greenfoot.gui.input.mouse.MousePollingManager.newActStarted(MousePollingManager.java:177)
at greenfoot.core.WorldHandler.startSequence(WorldHandler.java:635)
at greenfoot.core.WorldHandler.simulationChangedSync(WorldHandler.java:673)
at greenfoot.core.Simulation.fireSimulationEventSync(Simulation.java:746)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:495)
at greenfoot.core.Simulation.runContent(Simulation.java:193)
at greenfoot.core.Simulation.run(Simulation.java:183)
AND
greenfoot.ActorRemovedFromWorld
even though I surround the entire act method with if (getWorld() != null) and also the line before getWorld().removeObject(this) with if (getWorld() != null)
Also actors sometimes become invisible and frozen when removed and sometimes an actor will be moved to (0, 0) rather than disappearing from the world. (I found a old issue on the GitHub repository which is the same as this but it was apparently fixed(?))