Jester565 / SpyNinjaGame

3 stars 1 forks source link

What's the best way to place all GameObject in the reset() method of GameEngine #3

Open jtara1 opened 8 years ago

jtara1 commented 8 years ago

In my personal / private implementation I kept an ArrayList<ArrayList<Integer>> containing empty tiles on the grid then got a random coordinate from this list & removed it everytime I created a new GameObject for the Grid.

Right now we continually select a random column & row index then check if it's occupied and keep doing this until we find a spot of the Grid whose value == null

This could be an issue if almost all or all spots are filled up on the Grid.

Jester565 commented 8 years ago

This was an issue addressed by the professor when presenting the final project example. He acknowledged the issues existence but didn't seem to care about it too much. I doubt we need that level of error checking but later on we can implement this check. If it takes more than 400 tries to insert an element, we can iterate over the Grid to make sure that there are null elements. If there aren't any null elements, then throw an error.