Check out Grant Acedrex, our featured variant for April, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Game Courier. PHP script for playing Chess variants online.[All Comments] [Add Comment or Rating]
Aurelian Florea wrote on Wed, Feb 12, 2020 09:51 AM UTC:

So far I have tried this code for fast castling but it seems I'm far from the truth :)! I even have a misplaced return error I can't see!

sub castle;
local ATTACKED RPOS xdir;
if not flag #from:
die A King may not castle after it moves.;
endif;
if capture:
die A King may not castle to an occupied space.;
endif;
set ATTACKED ATTACKEDBYW unless isupper moved ATTACKEDBYB;
if fn var ATTACKED #from:
die A King may not castle out of check.;
endif;
set xdir minus file #to file #from;
if not checkaleap #from #to #xdir 0:
die A King may not castle there;
endif;
if sign minus file #to file #from:
if rank #to 1:
set RPOS a1;
else:
set RPOS a8;
endif;
else
if rank #to 1:
set RPOS j1;
else: set RPOS j8;
endif;
endif;
if not flag #RPOS:
die A king may not castle with a rook that moved;
endif;
move #RPOS #from;
unsetflag #from, #RPOS;
return true;
endsub;