diff options
author | Nils Wallménius <nils@rockbox.org> | 2007-09-02 10:11:46 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2007-09-02 10:11:46 +0000 |
commit | 5ccf18019ed9529564300dc13313705ab35b94b3 (patch) | |
tree | 09530f364102c0e315e8df72ec60e10244f2e78c /apps/plugins/chessbox/gnuchess.c | |
parent | c00652b0a222b6d5a25437b972d34d72619b00a8 (diff) | |
download | rockbox-5ccf18019ed9529564300dc13313705ab35b94b3.tar.gz rockbox-5ccf18019ed9529564300dc13313705ab35b94b3.zip |
Accept patch from FS#7174 by Mauricio Peccorini with canges by me and Igor Kuzmin, chessbox now saves played games in a pgn file called .rockbox/rocks/games/chessbox.pgn
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14575 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/chessbox/gnuchess.c')
-rw-r--r-- | apps/plugins/chessbox/gnuchess.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/apps/plugins/chessbox/gnuchess.c b/apps/plugins/chessbox/gnuchess.c index e72a489a0d..3574dd6fbe 100644 --- a/apps/plugins/chessbox/gnuchess.c +++ b/apps/plugins/chessbox/gnuchess.c | |||
@@ -1116,10 +1116,9 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt; | |||
1116 | /*OutputMove();*/ | 1116 | /*OutputMove();*/ |
1117 | 1117 | ||
1118 | short index; | 1118 | short index; |
1119 | for (index=0;index<4;index++){ | 1119 | for (index=0;index<5;index++){ |
1120 | move_buffer[index] = mvstr1[index]; | 1120 | move_buffer[index] = mvstr1[index]; |
1121 | } | 1121 | } |
1122 | move_buffer[index] = '\0'; | ||
1123 | 1122 | ||
1124 | if (score == -9999 || score == 9998) mate = true; | 1123 | if (score == -9999 || score == 9998) mate = true; |
1125 | if (mate) hint = 0; | 1124 | if (mate) hint = 0; |
@@ -2231,26 +2230,30 @@ void SetTimeControl( void ) | |||
2231 | ExitChess(); | 2230 | ExitChess(); |
2232 | }*/ | 2231 | }*/ |
2233 | 2232 | ||
2234 | int VerifyMove(char s[],short iop,unsigned short *mv) | 2233 | int VerifyMove(short player, char s[],short iop,unsigned short *mv, char *move_buffer) |
2235 | 2234 | ||
2236 | /* | 2235 | /* |
2237 | Compare the string 's' to the list of legal moves available for the | 2236 | Compare the string 's' to the list of legal moves available for the |
2238 | opponent. If a match is found, make the move on the board. | 2237 | player. If a match is found, make the move on the board. This was originally |
2238 | fixed for the opponent, but allowing the player to be specified will make | ||
2239 | possible to use GnuChess as a human vs human game verifier. It also allows | ||
2240 | the PGN functions to verify checkmates. | ||
2239 | */ | 2241 | */ |
2240 | 2242 | ||
2241 | { | 2243 | { |
2242 | static short pnt,tempb,tempc,tempsf,tempst,cnt; | 2244 | static short pnt,tempb,tempc,tempsf,tempst,cnt; |
2243 | static struct leaf xnode; | 2245 | static struct leaf xnode; |
2244 | struct leaf *node; | 2246 | struct leaf *node; |
2247 | short opponent_player = (player == white)?black:white; | ||
2245 | 2248 | ||
2246 | *mv = 0; | 2249 | *mv = 0; |
2247 | if (iop == 2) | 2250 | if (iop == 2) |
2248 | { | 2251 | { |
2249 | UnmakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst); | 2252 | UnmakeMove(player,&xnode,&tempb,&tempc,&tempsf,&tempst); |
2250 | return(false); | 2253 | return(false); |
2251 | } | 2254 | } |
2252 | cnt = 0; | 2255 | cnt = 0; |
2253 | MoveList(opponent,2); | 2256 | MoveList(player,2); |
2254 | pnt = TrPnt[2]; | 2257 | pnt = TrPnt[2]; |
2255 | while (pnt < TrPnt[3]) | 2258 | while (pnt < TrPnt[3]) |
2256 | { | 2259 | { |
@@ -2264,10 +2267,10 @@ struct leaf *node; | |||
2264 | } | 2267 | } |
2265 | if (cnt == 1) | 2268 | if (cnt == 1) |
2266 | { | 2269 | { |
2267 | MakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst); | 2270 | MakeMove(player,&xnode,&tempb,&tempc,&tempsf,&tempst); |
2268 | if (SqAtakd(PieceList[opponent][0],computer)) | 2271 | if (SqAtakd(PieceList[player][0],opponent_player)) |
2269 | { | 2272 | { |
2270 | UnmakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst); | 2273 | UnmakeMove(player,&xnode,&tempb,&tempc,&tempsf,&tempst); |
2271 | /*ShowMessage("Illegal Move!!");*/ | 2274 | /*ShowMessage("Illegal Move!!");*/ |
2272 | return(false); | 2275 | return(false); |
2273 | } | 2276 | } |
@@ -2283,10 +2286,20 @@ struct leaf *node; | |||
2283 | GameList[GameCnt].nodes = 0; | 2286 | GameList[GameCnt].nodes = 0; |
2284 | ElapsedTime(1); | 2287 | ElapsedTime(1); |
2285 | GameList[GameCnt].time = (short)et; | 2288 | GameList[GameCnt].time = (short)et; |
2286 | TimeControl.clock[opponent] -= et; | 2289 | TimeControl.clock[player] -= et; |
2287 | --TimeControl.moves[opponent]; | 2290 | --TimeControl.moves[player]; |
2288 | *mv = (xnode.f << 8) + xnode.t; | 2291 | *mv = (xnode.f << 8) + xnode.t; |
2289 | algbr(xnode.f,xnode.t,false); | 2292 | algbr(xnode.f,xnode.t,false); |
2293 | |||
2294 | short index; | ||
2295 | for (index=0;index<5;index++){ | ||
2296 | move_buffer[index] = mvstr1[index]; | ||
2297 | } | ||
2298 | if (SqAtakd(PieceList[opponent_player][0],player)){ | ||
2299 | move_buffer[4] = '+'; | ||
2300 | move_buffer[5] = '\0'; | ||
2301 | } | ||
2302 | |||
2290 | return(true); | 2303 | return(true); |
2291 | } | 2304 | } |
2292 | } | 2305 | } |