Since this pertains to both VB and maths, I'll post it here too, I might even get a better response :P
Here's three screenshots from a program I'm making, n=1, n=2 and n=3. You can see where it's going. With n=1 only one tile is selected, n=2 all the surrounding tiles, n=3 all the surround tiles of those tiles.
At the moment it's I just typed in a big mofo 'If' statement for the purposes of showing what it's supposed to do. What I need to do is work out some kind of algorithm that can do this automatically.
If anybody can help me out with this I'd greatly appreciate it.
OK, this is not a full algorithm, but at least a good start.
when n=0, don't do anything, when n=1, then fill in the tile.
when n=2 then:
origTile = tile that was previously filled in
also fill in:
origTile+9 'one below
origTile-9 'one above
origTile-5 'top left
origTile-4 'top right
origTile-5 'bottom left
origTile-4 'bottom right
obviously check those tiles exist first.
when n=3, insert all the previous tiles (from when n=2) into the same function. This is actually quite innefficient though as lots of points are being filled in lots of times. also you'll have to see that the colouring in of the tiles doesn't go from one side to other, eg if h=13 and n=2 then 8 and 26 shouldn't be filled in. Not quite sure how to do that.