Need help with a method to randomly lay mines in a minesweeper game
- by avatarX
So my Java minesweeper game is represented as a int[][] where -1 represents a mine. When I initialize my game I need to randomly place x amount of mines.
What is an elegant way of doing this? I was thinking of using an ArrayList with the coordinates of each cell, randomly selecting it, changing the state of the int[][] and then removing that Point. This would ensure that no point is selected twice.
Is there a more elegant way of doing this?