Grids and coordinates

时间:2017-06-12 16:45:04

标签: java coordinates

I've set up a grid of 52x52 black tiles, and now I want to create a method which will remove 52 black tiles and replace them with grey squares.

I do not want to apply these replacements purely at random, and I also do not want grey tiles to replace other grey tiles. My goal is to have an initial point which is randomly chosen to be replaced (which I have already done), then the next replaced tile is to be randomly selected from one of the 8 adjacent black tile surrounding that initial grey tile. When that is done I want one of the black tiles adjacent to the newly replaced tile to be selected and replaced, and so forth until I get 52 replacements.

I've being mulling it over for a little while now, and I can't figure out a way to pull it off. I can't lay every possibility out in a switch statement, as doing so would obviously be an impossibly lengthy feat. I considered trying to create an ArrayList to memorize the coordinates that have already been input which can be checked against whenever my program has selected a place to put a new tile, but I wasn't able to figure out how to store and compare the coordinates. Beyond that no solid solutions come to mind, just slight permutations of what I have already mentioned.

Do you have any advice on what course of action I could take here?

0 个答案:

没有答案