954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Chess...confusing problem =(

Well I don't have any specific question. I've been writing a chess game and can't seem to figuire out what the problem is with it! I tried debugging it for a few hours now and am about to give up altogether and rewrite it. The problem occurs seemingly randomly when the king is moved (on either team). It throws an access violation for some reason...and I can't seem to figuire out the exact circumstances that trigger it. I'm thinking the problem lies in the recent (and still pretty sloppy) additions of check, checkmate, and castling. Any help would be appreciated!! I would post the code but the project is pretty big at this point, so it's probably easiest just to download it (Project is attached). Thanks!

Attachments ChessEngine.zip (253.73KB)
skatamatic
Posting Shark
959 posts since Nov 2007
Reputation Points: 403
Solved Threads: 129
 

Your zip file appears to be corrupt. At least according to my copy of WinZip.

vmanes
Posting Virtuoso
1,914 posts since Aug 2007
Reputation Points: 1,268
Solved Threads: 228
 

I got it to open with 7-zip

MatEpp
Junior Poster in Training
79 posts since Jan 2009
Reputation Points: 21
Solved Threads: 12
 

Sorry I zipped it as rar then changed the extension to zip after I found out rar cant be uploaded. WinRar opens it fine! I don't have winzip =(. When I get home I'll get winzip and re-upload for you. I appreciate that some people are actually making an attempt to help debug it!

skatamatic
Posting Shark
959 posts since Nov 2007
Reputation Points: 403
Solved Threads: 129
 

And it seems you have archives within archives within archives?

And, shouldn't there be some implementation files for the various classes?

vmanes
Posting Virtuoso
1,914 posts since Aug 2007
Reputation Points: 1,268
Solved Threads: 228
 

Well before you do anything, might wana fix a lil problem w/ ur game.
Your pon can move 2 spaces even when its not its first move : /
I recomend saying if the pon is not in the start y axis, then it can only move 1 space, else it can move 2. Because pons cant move backwards, this will assure it works. But i havent looked at code first so i cant solve your problem yet. I will check.


also i moved the king allot and dident get any access violation. But i will see

u8sand
Junior Poster
131 posts since Dec 2008
Reputation Points: 78
Solved Threads: 15
 

Well before you do anything, might wana fix a lil problem w/ ur game. Your pon can move 2 spaces even when its not its first move : / I recomend saying if the pon is not in the start y axis, then it can only move 1 space, else it can move 2. Because pons cant move backwards, this will assure it works. But i havent looked at code first so i cant solve your problem yet. I will check.

also i moved the king allot and dident get any access violation. But i will see

hmmm yeah something must be horribly wrong with that entire project, because the pawn movement is fine >.< . Each piece has a bHasMoved member that represents whether or not it has moved, and the pawns use that to prevent them from moving more than 2 spaces after their first move.

i will redo the whole thing right now since the one i uploaded seems to be totally fried.

skatamatic
Posting Shark
959 posts since Nov 2007
Reputation Points: 403
Solved Threads: 129
 

Lol. Sorry about that everyone. Here's the new project that, other than the forementioned issue, is working fine. And regarding the implementation files, everything is inlined right now, so its all jammed in the headers. I will probably end up changing this when I start the AI to increase performance.

Attachments ChessEngine01.zip (102.74KB)
skatamatic
Posting Shark
959 posts since Nov 2007
Reputation Points: 403
Solved Threads: 129
 

Generally it's a good idea to abstract the problem into as simple and small piece of source code that you can rather than upload your entire project. This way when an answer is obtained, it will help others in the future as well, rather than just help the king move properly!

Dave

daviddoria
Posting Virtuoso
1,996 posts since Feb 2008
Reputation Points: 437
Solved Threads: 204
 

Generally it's a good idea to abstract the problem into as simple and small piece of source code that you can rather than upload your entire project. This way when an answer is obtained, it will help others in the future as well, rather than just help the king move properly!

Dave

Generally, I'd agree with you. But this source is somewhat complex, and as I had already explained I'm not sure where the problem is occurring. And I think that posting about 11 hours worth of work can be beneficial to others, seeing as chess source is hard to come by.

-Update - I think I may have the king working now, but now the checkmate seems to be failing! I'll post up when I get home tonight.

skatamatic
Posting Shark
959 posts since Nov 2007
Reputation Points: 403
Solved Threads: 129
 

can you sent me the movement of hourse in chess in c++ .thanks for help me my mail is robab_k67@yahoo.com

robab
Newbie Poster
1 post since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You