Check out Alice Chess, our featured variant for June, 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 Logs. View the logs of games played on Game Courier.[All Comments] [Add Comment or Rating]
Jose Carrillo wrote on Wed, Aug 3, 2016 09:06 AM EDT:

Hi Fergus,

In reviewing your solution for the Bare King rule problem, I see a variable called "status" which I can't find where in the Shatranj code is previous set. Is this a global variable? How does it work?

Thanks.

= = =

set checks sub checks #k;
if sub checkmated #k #checks and var checks:
  say Checkmate! White has won!;
  won;
elseif var checks:
  say Check!;
elseif sub stalemated #k:
  say Stalemate! White has won!;
  won;
endif;
if == 1 count onlylower and == status Ongoing:
  set mypieces onlyupper;
  switch count #mypieces:
    case 1:
      say Both Kings Bared! Game Drawn!;
      drawn;
      break;
    case 2:
      foreach (from piece) #mypieces:
        if == #piece K:
          continue;
        elseif not fn k #k #from or fn K #K #from:
          say Bare King!! White Wins!!;
          won;
          break;
        else:
          say Both Kings Bared on Next Move! Game Drawn!;
          drawn;
          break;
        endif;
      next;
      break;     
    default:
      say Bare King! White Wins!;
      won;
      break;
  endswitch;
endif;