[Tfug] random squares
Andrew Ayre
andy at britishideas.com
Sun Oct 21 13:00:47 MST 2007
Oops - missed a bit. If the random square is taken (array[x,y] = 1) then
keep generating random x,y until you get one that isn't taken.
christopher floess wrote:
> Hi, everyone. I have to write a program in java that
> involves a 2d array as a game board. Given a number
> in the constructor, I have to assign that many squares
> to be 'mines'. I know I could use math.random(), but
> would anyone recommend a better way to do this?
>
> ~ Chris
>
>
--
Andy
PGP Key ID: 0x67090A54
More information about the tfug
mailing list