| Author |
Message |
Malcolm James Webb (Mjw)
New member Username: Mjw
Post Number: 3 Registered: 5-2008
| | Posted on Friday, April 15, 2011 - 10:54 pm: | |
I am working on a checkmate game where there is a move that is only possible if it is the only way to escape check. My method was: (move-priorities normal-moves emergency-moves) (piece (name King) ...description/help/image etc... (moves (move-type normal-moves) (shift n) ...etc (move-type emergency-moves) (escapemove) )) The problem is that when I set up a position where escapemove is the only way for the King to get out of check, Zillions does not generate escapemove, instead it says the King is checkmated! Escapemove works fine if it is defined as a normal move, but I want to ensure that it works only as a last resort for the King. Does anyone have any suggestions? |
M Winther (Kalroten)
New member Username: Kalroten
Post Number: 144 Registered: 1-2007
| | Posted on Saturday, April 16, 2011 - 7:22 am: | |
I don't understand why it doesn't work. Are you sure you have programmed escapemove correctly? Another version would be to make escapemove a normal-moves but you check first that the squares in the orthogonal directions are either occupied by a friendly piece or threatened by an enemy piece (attacked? n) etc. But you should first check that there is no friendly piece on it as (attacked?) is costly. /Mats |
Malcolm James Webb (Mjw)
New member Username: Mjw
Post Number: 4 Registered: 5-2008
| | Posted on Sunday, April 17, 2011 - 6:11 am: | |
Thank you for replying. Yes, I did program escapemoves correctly. The game comes in three variants: a) escapemoves is made only when the played cannot get his King out of check any other way; b) escapemoves is available when the King is in check, regardless of whether there are other moves available; c) the King can make escapemoves whether or not it is in check. Variant b) & c) work fine: variant a) finds itself checkmated when the King cannot make any other move to escape check. I did think of your solution: however this would only ascertain that the King cannot make any other move out of check. I want to exclude the possibility that the player can escape check by using another piece to capture or interpose before escapemoves becomes available. |
M Winther (Kalroten)
New member Username: Kalroten
Post Number: 145 Registered: 1-2007
| | Posted on Monday, April 18, 2011 - 12:32 am: | |
You could always change the checkmate criterion to captured king. After all, checkmate is merely an "aesthetic" rule. It's really the same as capture of king. In this case escapemove will be performed. /Mats |
M Winther (Kalroten)
New member Username: Kalroten
Post Number: 146 Registered: 1-2007
| | Posted on Monday, April 18, 2011 - 10:41 am: | |
I think I know why it doesn't work. It's because there still exist 'normal-moves', it's just that the king will be captured if the king makes the move. So there is an alternative way to solve this, if you don't want to use 'captured king' instead of 'checkmated' (see above). At each king move you can check whether it's 'attacked' (i.e. in check). If 'attacked' then you check whether all the escape squares are also attacked, in which case you execute escapemove. /Mats |