|
|
Topic: Threefold repetition rule
| |
|
Author
| Message |
|
I'll think about your idea, it might work. Thanks!
|
|
Welcome, Miguel! Hope I can help, at least giving ideas. :-)
|
|
Good!
|
|
Nice!
|
|
Another option, but this one I'm not sure if it's easy: We do have the option to ask for a draw at any move, alright? What if I click this option, make my move and, after clicking "Play", server recognizes that? It wouldn't bring a post-move command, neither be against any rule. :) |
Too heavy... :-(
I believe in something like an post-move analisys. IMHO, too more simple, fast, clean and economic... :-)
The (b) case is already catched... So, for (a) case: Like Miguel's amd andreavb's solution: a button clamming the draw before the move, server analisys it and give (or not) the draw.
To do the FEN, I believe that you use a function, right?
So, I would do something like:
<?php
/* Preventing SQL Injection... */ $pattern = "/[]\[\'\"\(\)\.,;:\`~!$#&|\\/]/";
$game_id = intval( addslashes( preg_replace( $pattern, "", $_GET["id"] ) ) );
$query = "SELECT COUNT(move) as number_moves, move FROM games WHERE game_id='$game_id' LIMIT 1";
$result = @mysql_query( $query ) or die ( my_error_handler() );
$moves_object = mysql_fetch_object( $result );
/* moves == string array ? */
$moves = $moves_object->move; $move_number = $moves_object->$number_moves;
/* assuming that the moves are stored as: moves[#MOVE] = move white, move black
and that moves are separated by a comma ',' */
$first_position = $move_number-2; // Number of moves to First Position $secon_position = $move_number-1; // Number of moves to Second Position
${move_.$first_position} = $moves[ $first_position ]; /* First postion */ ${move_.$secon_position} = $moves[ $secon_position ]; /* Second postion */ ${move_.$move_number} = $moves[ $move_number ]; /* Third postion */
$fen_first_position = make_fen( ${move_.$first_position} ); $fen_secon_position = make_fen( ${move_.$secon_position} ); $fen_third_position = make_fen( ${move_.$third_position} );
if ( ( strcmp($fen_first_position, $fen_secon_position) == 0 ) && ( strcmp($fen_first_position, $fen_third_position) == 0 ) && ( strcmp($fen_secon_position, $fen_third_position) == 0 ) ) { // Positions are same. Can clain for draw? True. } ?>
But this recognizes just last three moves... With some modification, it can work 100%.
Probably something about comparing positions whithout pawn moves would do it fine...
If you want, I can think about it... :-)
HTH... :-)
|
Previous 1 2 3 4 5 Next |
|
|
|