Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Flow Game Solver

Name: Anonymous 2012-12-26 21:39

Heya fellas, I was just wondering if you could give me a push in the right direction with this simple program I'm writing.

So I downloaded this game, Flow, for my phone and I am unable to solve two of the puzzles. In essence, there is a square grid with two of multiple colors (two reds, two blues, etc.) that one must connect while filling up the entire grid and without crossing lines. My program will take any set-up of initial positions and colors and make the necessary movements, which are ones that MUST be taken, of course. As in this picture:
http://imgur.com/mo6D3

I'm now wondering how I should handle the brute force action that I have concluded to be the simplest way. Right now I have a  two dimensional array filled with structs that hold info like color, whether the block is either of the ends of the 'snake' that the colors make, and which directions the blocks have been entered from or exited from.

My idea right now is to make a vector of these arrays and push and pop different iterations of them until a single color is finished (the two ends are connected), then begin on the next. I realize this will take a lot of time for bigger grids.

Anything you guys could think of that may help me out here? I feel like I'm going about it the hard way.
Btw, I am programming in C++.

Name: Anonymous 2012-12-28 23:16

So I've run into another little problem. I've always had some trouble with references and pointers, unfortunately.

What I want to do, to avoid continually searching through my 2D array of structs, is create a sort of reference I think.

For example, I'd like to define a variable x to be the same as an index in the array, say array[0][0]. Whenever I change x, array[0][0] changes accordingly. In essence, x IS array[0][0], but with a much simpler name to deal with.

Is this possible? I've tired messing around making pointers and references willy nilly, but I'm not making any headway.

Name: Anonymous 2012-12-29 5:17

>>21
Thank you.
I think I tried this, but I'll have to check again in the morning. If the array is of structures, how would I write to its individual index's parts through the referenced pointer?

*x.whatever = w     ?

And will I have to keep resetting *x = &array[0][0] so it knows what it'll be writing to? Or does the initialization permanently tie it to that array index in memory?
I've got a buzz on, please forgive.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List