Othello game in C++, having trouble with my recursive function, any help would be apprechiated

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
This is everything.... Take a look, it doesnt work :(


It always goes to invalid move and it wont play :(


Thanks for all help...

I think its the check direction function the problem, cause its always returning 0...

Thanks again
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
I'm surprised it's even running since it looks like you disabled the (incorrect) bounds check. You're lucky to not get a memory protection error form accessing elements [ -1 ] and [ 8 ] .

If you have a decent debugger, you should be able to set breakpoints and step through the recursion and see where it is incorrectly returning 0. This is a skill you need to learn anyway.
 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
Originally posted by: DaveSimmons
...

If you have a decent debugger, you should be able to set breakpoints and step through the recursion and see where it is incorrectly returning 0. This is a skill you need to learn anyway.

I was about to suggest this, as well. I don't know Othello. Two popular IDEs are available for free with built in debuggers, Dev-C++ and Visual C++ Express Beta.
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Originally posted by: DaveSimmons
I'm surprised it's even running since it looks like you disabled the (incorrect) bounds check. You're lucky to not get a memory protection error form accessing elements [ -1 ] and [ 8 ] .

If you have a decent debugger, you should be able to set breakpoints and step through the recursion and see where it is incorrectly returning 0. This is a skill you need to learn anyway.

Ive been going through the code all afternoon, changed stuff around quite a few times, cant get it at all...

If someone could just point me in the right direction and tell me where the problems are exactly, or just change the code so I can understand it, it would be apprechiated.

Thanks
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Originally posted by: diegoalcatraz
Originally posted by: DaveSimmons
...

If you have a decent debugger, you should be able to set breakpoints and step through the recursion and see where it is incorrectly returning 0. This is a skill you need to learn anyway.

I was about to suggest this, as well. I don't know Othello. Two popular IDEs are available for free with built in debuggers, Dev-C++ and Visual C++ Express Beta.

Im using Visual C++, been using the debugger, cnt never gets augmented...
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Zip up the complete project and e-mail it to me. Will take a quick look at it tommorrow AM.
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Originally posted by: EagleKeeper
Zip up the complete project and e-mail it to me. Will take a quick look at it tommorrow AM.

Everything is posted. Im only using one file right now, for testing, ill make everything beautiful and add some header files later on.

Thanks for your help
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
heres the latest ive come up with:

It works most of the time, but theres still bugs..


Like, if you move, and 2 moves are valid (left, and left up), then it will change both, not in a straight line..


Heres what I come up with, but I need a better solution...
when ValidMove gets checked, ill make it call up checkdir 8 times, and find which direction has the most flips to make, which ever has greatest flip, flip that way.....

Makes sense?

Thanks.
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
updated the code for the valid move, seems to be good so far

going to have to do some testing tomorrow, its 3:30 :eek:

Good night atot
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Heres the LATEST code, Its working, but has trouble with the check direction.

When you play, if you move, itll do every move it can find (if the token beside it is the opposite color, it flips it) even when its not supposed to, try it out, youll see what I mean..

If anyone could point me in the right direction it would be apprechiated
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Originally posted by: Red and black
This wouldn't be your homework, would it?

Its a project thats due in 3 weeks. I wanna get it done fast so I can have time for other projects.

If you dont wanna help dont.
 

fishbits

Senior member
Apr 18, 2005
286
0
0
Red and black: Homey's actually come in with a lot of code and is actively working on it though. Not the "I hope/expect someone to do all of my work for me while I play Grand Theft Auto" request.
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Originally posted by: fishbits
Red and black: Homey's actually come in with a lot of code and is actively working on it though. Not the "I hope/expect someone to do all of my work for me while I play Grand Theft Auto" request.

:thumbsup:

im still having trouble with the checkdir function...

I dont want it to go over the squares it shouldnt, u know, err :( im lost. need help