QueenAlice.com


Username:

Password:

Remember me



Forgot Password?
Registration FREE!





Topic: Threefold repetition rule
Back to Forum Index
Back to Forums List


Author

Message
shirya00007India flag
may be this could be simpler

store the string of game postion & gameID somewhere(e.g. 7k/pp4pp/2pq1p2/8/3P3P/2Q3P1/1r2rP2/5RK1)...and search for current postion whether it exists twice in this list after every move

whitekingsSingapore flag
Shirya - for threefold repetition to occur, it must be the same side to move and there must be no change in the legal moves available. Perhaps the program could check these after finding a match.

davividalBrazil flag
shirya00007, I believe that my solution is simpler... 8-)

Why? Because if I store _every_ game position somewhere (aka. file or DB), it'll demand much computer processing... Think about that:

1 - Check if actual position aren't already stored;
2 - If stored, do nothing. Otherwise, store it indexed by gameID.

1 - Get _all_ the positions from the "gameID" and compare its positions _every_ move.

Too heavy... Get a game with 30 moves... You'll store 60 game positions. You'll recover and compare all the 60 game positions...

Well... I'm playing 28 games... You're playing 41 games...
If each of these games has about 30 moves, we've something about 4140 game positions stored and becoming compared... :-) :-O
Oh! I'm calculating it just with my and yours games... :-)

Did you get the point? ;-)

richerbyUnited Kingdom flag

davividal wrote: Because if I store _every_ game position somewhere (aka. file or DB), it'll demand much computer processing...

You only need to store the positions since the last capture or pawn move. That cuts it down a lot -- it's fairly rare to go more than, say, 15 ply without such a move.


we've something about 4140 game positions stored and becoming compared...

Computers are very good at this kind of trivial data-munging, you know. ;-)

davividalBrazil flag

Computers are very good at this kind of trivial data-munging, you know. ;-)


Not at all... ;-)
Trust me... :-)
You aren't comparing 4k identical strings...

Remember: Strings are Char vectors... ;-)
One Char consits by 1 byte.
An FEN position consists by, at least of 56 chars:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1


You need:
1 - Start a new fork of the web server (something about 0.1 MB RAM);
2 - Call the PHP interpreter (alocate memory);
3 - Start the script (alocate memory);
4 - Get the database constants;
5 - Get the current opened connection OR open a new connection (more memory);
6 - Consult the database and get the position X, X-1 and X-2 (all the 3 results are stored at memory... 56 * 3 = 168 Bytes);
7 - Generate the rest of page (menus, board, etc.);

168 Bytes is a very small number... But... You must consider the Database connection, the Web Server connection, the connection pipe, the memory garbage and much more things...



Previous 1 2 3 4 5 Next

©2004-2024 Queen Alice Internet Chess Club
All rights reserved.