I'm doing an University Project with Greenfoot that consist of creating a chess game that plays by itself. Now I already done much of it, but now I'm facing with a problem: every time a CPU player is doing a move there will be a method that randomize the selected piece and if it cannot do anything, it will pass to a second randomize piece. The problem comes when someone begin to eat the pieces, because those objects will be removed, and the next move if those pieces are selected to do something it will give me the error that the actor is not in the world. What I'm asking is if there is a way, a condition, a method to know if the object exist in the world so that I can skip that object till I find one that exist.
Thanks in advance