| Author |
Message |
Frank Pi (F314)
| | Posted on Friday, July 28, 2006 - 7:20 am: | |
Hi, I'm trying to create a non-standard way of castling in a chess-like game: in the initial position, Rook is on a1, King on c1. (b1 already empty) After castling, King should be on b1, Rook on c1. The problem is : To choose the castling-move(and distinguish it from the normal king-move to b1) one should be able to drop the King two cells left (over the Rook). So far so good. But then the King should not land on the chosen cell (a1) but on b1. I don't know if that is possible at all. Can anyone give me a hint if (and how this could be realised? greetings, Frank. |
Mats W (Kålroten)
| | Posted on Friday, July 28, 2006 - 12:45 pm: | |
Frank, This move is possible with another piece than the king, but if the king is involved, and as the king is captured from the a1 square, then it satisfies a lost-condition. However, you could also simply move the king to b1. If the move is ambiguous, then Zillions will pop up a window and ask whether you mean to castle or merely move the king to b1. Perhaps you should use this function instead, as people are more used to castle by moving the king directly to the destination square. In that case you could write something like this: w (verify empty?) w (verify (piece? Rook)) e cascade w from back add) But you could also choose the alternative to castle by dropping the rook on the king. Then you could write like this: e (verify empty?) e (verify (piece? King)) cascade from w add (I suppose you must also verify that the rook and the king hasn't moved). Mats |
Frank Pi (F314)
| | Posted on Friday, July 28, 2006 - 1:56 pm: | |
Hi Mats, thx for your answer. yes, i thougth of this already, to "castle with the rook". and it works. (the version with popup i'm not enjoying) i found this very interesting, why this simple combination with king & rook isn't possible (from the king-side). i thought, maybe after king and rook have changed position (this is possible), somehow additionly the king could be moved to b1 in this case of castling. but i couldn't do this yet. Frank. |
Mats W (Kålroten)
| | Posted on Sunday, July 30, 2006 - 3:34 pm: | |
Of course, you could solve it by a partial move. This means that the user drops the king on the rook, and then moves the king once again to b1, something like this: w (verify empty?) w (verify (piece? Rook)) cascade from back (add-partial king-move) Mats |
Angelino (Carmino)
New member Username: Carmino
Post Number: 1 Registered: 9-2008
| | Posted on Monday, September 01, 2008 - 7:20 am: | |
I have the same question as Franck. I am quite new and do not program. Rook on A1 and King on C1. After castling the king is on B1 and the Rook is on C1. I managed to enable castling and I get a pop-up menu. Can you check it this code is clean ? Thanks. It must verify it the squares are not attacked, the King does not escape from a check by castling and the rook and king have not moved. I think this part needs to be cleaned. define O-O ( (verify never-moved?) w ; B1 (verify empty?) w ; A1 (verify (and friend? (piece? Rook) never-moved?) ) ; Rook ? not moved ? e ; B1 Here the King cascade w ; A1 from back add (verify (and friend? (piece? Rook) never-moved?) ) ; Save expensive not-attacked?s for last (verify not-attacked?) e ; KB1 (verify not-attacked?) to (set-attribute never-moved? false) ; We could check if KN1 is attacked too, but this isn't ; really necessary since Zillions doesn't allow any moves ; into check e ; Rc1 (set-attribute never-moved? false) add ) |
john mclain (Louden)
New member Username: Louden
Post Number: 1 Registered: 6-2009
| | Posted on Saturday, June 27, 2009 - 6:15 pm: | |
The problem with the above code is that you and the AI can now castle out of check which is an illegal move, is there more you can add to the code to stop this? anyone? |
M Winther (Kalroten)
New member Username: Kalroten
Post Number: 119 Registered: 1-2007
| | Posted on Sunday, June 28, 2009 - 2:22 am: | |
John, you simply add (verify not-attacked?) /Mats |
john mclain (Louden)
New member Username: Louden
Post Number: 2 Registered: 6-2009
| | Posted on Sunday, June 28, 2009 - 6:01 am: | |
Hi there, sorry you'll have to forgive me i'm new to scripting, but isn't (verify not-attacked?) already present in the above code? It's just i played this code yesterday and the AI castled out of check. Thanks. |
M Winther (Kalroten)
New member Username: Kalroten
Post Number: 120 Registered: 1-2007
| | Posted on Sunday, June 28, 2009 - 12:38 pm: | |
It sems to be a programming error. He does (verify not-attacked?) on the rook's position instead of the king's position. But the rook is allowed to be attacked. It should be easily corrected by moving this code line to its correct place. /Mats |
M Winther (Kalroten)
New member Username: Kalroten
Post Number: 143 Registered: 1-2007
| | Posted on Monday, February 14, 2011 - 2:10 am: | |
I have now realized that it's possible to do what Frank wants in the initial question. The problem is that the king shall be dropped on the rook at a1, but the king should end up on b1. So one needs to capture the king on a1, but this triggers a checkmated-condition. However, if one does "change-type" into a dummy piece before capturing, then the checkmated condition isn't triggered. Then one creates a new king on b1 and a new rook on c1. I have tested it, it works. |