C++ help

sorry karym, just saw your post.

My question is why would you need to know your immediate neighbour? If you do, you would need to store 8, right?

I gave sample code just to give an idea to help fes along.

Im so rusty, its probably full of holes anyway ;)
 
lol, dont do it for him!!! He needs to learn himself!!!

Checking the winning constraint is possibly the trickiest thing to do elegantly. Would you check each marker at the end of each move for instance? And how would you do that? One way would be to test via cardinal points. If there is a marker with another marker to its south of the same colour, then you could check the same thing again. You would end up with a nice little function.
 
sorry karym, just saw your post.

My question is why would you need to know your immediate neighbour? If you do, you would need to store 8, right?

I gave sample code just to give an idea to help fes along.

Im so rusty, its probably full of holes anyway ;)

No you wouldnt. For instance (and I will purposefully not put code here), you would have a function that checks for markers adjacent to the one you have just placed. For each marker you place, you would store in the array a cardinal point of another marker that matches its colour.

next, you would have another function that checks along these cardinal points for a win condition. You dont need to waste time looking for a loose, the only additional thing you would need is a draw condition - this is where the number of moves comes in. Once the total slots on the gris - the total number of moves = 2 (I think) then you have a draw.
 
yes, good idea. Certainly would save iterating thru the arrays after each move. As I said, not the most efficient, but would get fes thinking logic, thats for sure!
 
ok cheers 4 ur help guys

so am i right in thinking that if i had a function for displaying the marker a player has just made

and a seperate function to check for any winners

and a seperate function to do the search?

remeber this is only half of my problem

once i get 2 players working against each other
then i will have to introduce a player vs computer ai

and plus i have to put these in seperate source files?

sorry for sounding thick
 
all depends on what route you want to take. you could start off with something simple, then develop it further. Main thing is you get the basics going. Karym as given you ideas outside of using 2d arrays.

With source files, you want to look at creating classes. I think initially you will just need the one with different methods.
 
True, a file with all your search functions as public classes etc is a good way of looking at it.

Gives you a nice bundle of re-usable code that your tutor will love you for.
 
Back
Top