Check out Modern Chess, our featured variant for January, 2025.


[ 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 Developer's Guide. Learn how to design and program Chess variants for Game Courier.[All Comments] [Add Comment or Rating]
Thomas wrote on Sun, Jan 4, 2009 03:10 PM UTC:
Thank you for the fixes and explanations. But you have overlooked that in
sub 'enpassant' there is twice 'filename' used.
It should be 'filename #to rankname #from'.

To check if any piece or any empty square is attacked, one could use the
following subroutine:


// This subroutine checks whether 'square' is attacked by the given
side:

sub attacked square bywhite:
  local from piece pawn pdir;
  if #bywhite:
    def enemies onlyupper;
    set pawn P;
    set pdir 1;
  else:
    def enemies onlylower;
    set pawn p;
    set pdir -1;
  endif;
  for (from piece) fn enemies:
    if == #piece #pawn:
      if checkaleap #from #square 1 #pdir or
         checkaleap #from #square -1 #pdir:
        return #from;
      endif;
    elseif fn #piece #from #square:
      return #from;
    endif;
  next;
  return false;
endsub;