I am currently creating code for a simple game and the required task asks 'Place tiger in a random VACANT location (from 0-23) on the Board'.
I understand how to use random to generate a random integer but do not know how to repeat until the action has been performed.
I have bd.isVacant() to check if a particular spot is vacant and rn which generates a random number. If I did something like x = (int) rn * 24 and than ran if(bd.isVacant(x)){condition} would that just happen once? I need it to keep trying until random vacant position is found.
Any help is appreciated, thankyou!
Aucun commentaire:
Enregistrer un commentaire