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;
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;