You could convert the array into two nine-bit values, one for the O positions and one for the X position, and a count of blank spaces: x_mask = 0 y_mask = 0 empty_count = 0 mask = 1 for each square if x then x_mask |= mask if y then y_mask |= mask if empty then empty_count++ mask.
A simple "structured" approach If you think of the board as: A B C D E F G H I Then one minimal selection of boxes that any winning layout must touch would be: A B C D G You can conceive the movement from any of these locations in a winning line in terms of a shift of 0, 1 or -1 positions in each of the X and Y directions. We can list the movements that you'd need to check: A: (++x) (++x, ++y) (++y) B: (++y) C: (++y) (--x, ++y) D: (++x) E: (++x) In C++, you can create a list/vector of the x/y coordinates of the starting points and the +/-/0 x/y movement deltas shown above, then use three nested loops to evaluate each line across the board. This is considerably more work than just hardcoding the two loops over x and y coordinates and the two diagonals (below), but it's a more algorithmic approach that might appeal intellectually: more like what you might have to do if you were handling a much bigger board.
Obvious brute force approach For the record, that simpler approach would look like this: int x; for (row = 0; row.
I tried to sort of do the brute force approach you mentioned because it made the most sense to me, but it looks like I messed it up. I edited the original post with my problem – Michael Mar 8 at 13:42.
I suppose you could assign each winning board possibility a number (basically a hash value) and then check if the current board matches any of the values in the table by generating its hash value. On the other hand, I wouldn't suggest spending too much time trying to make the CheckWin function super-efficient. Unless it's being called millions of times or something and needs to be really fast, spend your time on something else--it probably won't be a bottleneck.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.