Check out Smess, our featured variant for February, 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

0000000100000000[Subject Thread] [Add Response]
H. G. Muller wrote on Wed, Sep 14, 2016 08:41 AM EDT:

> The html code posted earlier doesn't enforce the rule that the pawn can promote to almost a rook on ranks 8 and 9 so you must decline manually not to promote to an aanca, griffin, queen , archbishop, marshall.

It also does not allow you to refrain from promotion: there is no 'P' in the promoChoice.

If you really want this to be handled automatically, you can add the following text to the HTML:

<script>function WeirdPromotion(x1, y1,x2, y2, promo)
{
  if((board[y1][x1] & 15) != 1) return promo; // moved piece is not a Pawn
  if(y2 == 9 || y2 == 0) return ((promo & 15) == 1 ? promo+4 : promo); // on last rank: cannot stay Pawn
  if((promo & 15) > 4) return board[y1][x1]; // larger than Rook: remains Pawn
  return promo; // choice was acceptable
}
</script>

In Capablanca Chess A + P is slightly stronger than Q, and I don't expect that tobe much different here.

 

[Edit]The promotion code above assumed a piece ordering P N B R Q ..., so that 1 is Pawn, 4 = Rook and 5 = Queen. I see now that you did not define the pieces in that order, and you would have to adapt that,or the code.