| Author |
Message |
Tony Britton (Captain)
New member Username: Captain
Post Number: 12 Registered: 12-2009
| | Posted on Friday, February 12, 2021 - 2:29 pm: | |
Using (verify not-attacked?) does not seem to work, if for example the attack is coming from a slide move from the West and the square to the East is not under attack do to your king is between the attacking piece and the square to the east of the King. So Zillions will let the king move to the square to the East even though it is still attacked from the sliding piece from the West. has anyone else encountered this and if so do you have a solution? |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 35 Registered: 3-2018
| | Posted on Saturday, March 06, 2021 - 12:07 am: | |
The sliding attack does not reach the square blocked by the piece itself, and this square's "attacked?" flag becomes "false" (it means "not-attacked"). A King escapes there (actually is "attacked"), since mistaking that the square is "not-attacked". This is a problem "Shadow attack line". |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 36 Registered: 3-2018
| | Posted on Saturday, March 06, 2021 - 12:16 am: | |
Look at this image! https://img.atwikiimg.com/www65.atwiki.jp/zillionsofgames/attach/485/1152/screenshot.PNG |
Tony Britton (Captain)
New member Username: Captain
Post Number: 14 Registered: 12-2009
| | Posted on Saturday, March 06, 2021 - 1:55 pm: | |
So it is a Logic flaw in the program! Have you ever tried to write a move construct where the piece moved checks to see if it's King is attacked after it has moved to a space and if true it moves back to its original space. or as a cascade where the second move is a dummy piece that confirms their king is not-attacked and if it is attacked the move is canceled. |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 37 Registered: 3-2018
| | Posted on Saturday, March 06, 2021 - 6:58 pm: | |
There are three ways to solve this problem. The first is possible with ZoG (I've implemented it). Use "move-type" to determine by what attack is attacking the King and limit the movement of the King. I'll give you an example of the code later. The second method is to determine in advance whether it will be a checkmate after a virtual move. It's versatile, but this requires the implementation of the flag "checkmated?" by ZoG. This method is adopted in the software for the improved version of ZoG that I am creating. Please see the animation GIF on the following page. https://w.atwiki.jp/zillionsofgames/pages/504.html The third is to mark the square behind the attack target as the shadow attack range, in the line-attack by the running pieces such as a Queen, Rook and Bishop. |
david bennett (Dpoly)
New member Username: Dpoly
Post Number: 28 Registered: 4-2017
| | Posted on Saturday, March 06, 2021 - 10:17 pm: | |
You are creating a new version? Care to say more? |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 38 Registered: 3-2018
| | Posted on Saturday, March 06, 2021 - 10:28 pm: | |
The first method: Sample Code) <<move-define>> (define king-shift-V ( (verify (not-attacked? V-line) ) $1 (verify not-attacked?) (verify not-friend?) (set-attribute never-moved? false) add ) ) (define king-shift-H ( (verify (not-attacked? H-line) ) $1 (verify not-attacked?) (verify not-friend?) (set-attribute never-moved? false) add ) ) (define king-shift-D1 ( (verify (not-attacked? D2-line) ) $1 (verify not-attacked?) (verify not-friend?) (set-attribute never-moved? false) add ) ) (define king-shift-D2 ( (verify (not-attacked? D1-line) ) $1 (verify not-attacked?) (verify not-friend?) (set-attribute never-moved? false) add ) ) <<piece-setup>> (piece (name King) (attribute never-moved? true) (moves (king-shift-V n) (king-shift-V s) (king-shift-H e) (king-shift-H w) (king-shift-D1 nw) (king-shift-D1 se) (king-shift-D2 ne) (king-shift-D2 sw) (O-O) (O-O-O) ) ) |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 39 Registered: 3-2018
| | Posted on Saturday, March 06, 2021 - 10:30 pm: | |
<<piece-setup>> (piece (name Queen) (moves (move-type V-line) (slide n) (slide s) (move-type H-line) (slide e) (slide w) (move-type D1-line) (slide nw) (slide se) (move-type D2-line) (slide ne) (slide sw) ) ) (piece (name Bishop) (moves (move-type D1-line) (slide nw) (slide se) (move-type D2-line) (slide ne) (slide sw) ) ) (piece (name Rook) (attribute never-moved? true) (moves (move-type V-line) (rooke-slide n) (rooke-slide s) (move-type H-line) (rooke-slide e) (rooke-slide w) ) ) Look at this image! https://img.atwikiimg.com/www65.atwiki.jp/zillionsofgames/attach/504/1154/ScreenShot.png |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 40 Registered: 3-2018
| | Posted on Saturday, March 06, 2021 - 10:42 pm: | |
In that sample code, follows is only used. (loss-condition (White Black) (captured King) ) Not used follows. (loss-condition (White Black) (checkmated King) ) In other words, that methods assess the square attacked by "shadow line attack" and exclude there from the escape route of a King without using the checkmate judgment. I have adopted it in my ZRF works past released. |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 41 Registered: 3-2018
| | Posted on Saturday, March 06, 2021 - 11:24 pm: | |
I understand that you are trying to implement the "second method" in ZRF code. But it's technically very difficult. Because it is necessary to save the state of pieces and squares before the virtual move and return to the saved state when it is judged as a checkmate. In the case that way is not used, also the problem of "discovered attack" will occur by the movement of "pinned" ally piece. I think the first and third method is useful for asses the square behind the King is attacked or not. I'm glad if you can use it as a reference. |
Tony Britton (Captain)
New member Username: Captain
Post Number: 15 Registered: 12-2009
| | Posted on Sunday, March 07, 2021 - 10:23 am: | |
Thank You Wantanabe, If I understand you correctly, If I define each direction of slide movement as a different type. Then the engine looks for all squares of attack as if the king did not block it. Do I need to use the win condition as captured king instead of an absolute-config for this to work, as you demonstrated? I am trying to create a pass move that can only happen when the king is in a mate position (define king-pass1 ( (verify (not-in-zone? Triangle)) (verify attacked?) mark $1 (verify (or (attacked? n ) (or (friend? n ) (or (not-on-board? n )(or (attacked? nn) (or (friend? nn) )))))) (verify (or (attacked? ne) (or (friend? ne) (or (not-on-board? ne) )))) (verify (or (attacked? e ) (or (friend? e ) (or (not-on-board? e )(or (attacked? ee) (or (friend? ee) )))))) (verify (or (attacked? se) (or (friend? se) (or (not-on-board? se) )))) (verify (or (attacked? s ) (or (friend? s ) (or (not-on-board? s )(or (attacked? ss) (or (friend? ss) )))))) (verify (or (attacked? sw) (or (friend? sw) (or (not-on-board? sw) )))) (verify (or (attacked? w ) (or (friend? w ) (or (not-on-board? w )(or (attacked? ww) (or (friend? ww) )))))) (verify (or (attacked? nw) (or (friend? nw) (or (not-on-board? nw) )))) back add-copy add)) The other way I was talking about is for keeping the other pieces from making a move that will leave their king in check. Basically to keep them from making an illegal move, as in my rules if you are in check on your turn, you must get out of it or pass. Whether you get out of it by moving, blocking or if you are in the position to capture the checking players king. That's why I thought making each piece have a cascade movement that had each player second piece be a dummy piece that scans the board to verify that the king is not in check once the primary piece is moved to its position would stop the move if the king is still attacked and should create a forced pass scenario. After I get the slide check scenario fixed that will be next. The you for the links. I like your GUI. I did not realize that you could change the toolbar graphics. Yours are much more upbeat the the originals, Please let me know which of your games you implemented this solution. So I can play them and look at the coding. You also mentioned that you are creating a new version. Will it have the ability to make checkmated a forced pass condition? Or a way to change the value of the pieces without adding extra off board moves? That would sure make it a lot easier to code games with more than two players. Plus it would considerably cut down the loading time and time between moves, since Zillions seems to reload itself every move. Thank You Again, Tony |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 42 Registered: 3-2018
| | Posted on Sunday, March 07, 2021 - 8:55 pm: | |
> Do I need to use the win condition as captured king instead of an absolute-config for this to work, as you demonstrated? No, "Captured King" is not necessary. It doesn't matter what "win-condition" is. However, "Checkmated King" automatically assess the "shadow attack line" to a King. By using that method for pinned pieces, you can also judge the "discovered attack". For that purpose, you need to evaluate the flag "pinned?" in advance. |
Shigeki Watanabe (Watanabe)
New member Username: Watanabe
Post Number: 43 Registered: 3-2018
| | Posted on Sunday, March 07, 2021 - 9:19 pm: | |
<<pin-define>> (define pin (if (attacked? $1) (while (empty? $2) $2) (if (and (piece? King $2) (friend? $2) ) (set-flag pinned? true) ) back (while (empty? $3) $3) (if (and (piece? King $3) (friend? $3) ) (set-flag pinned? true) ) back ) ) <<piece-setup>> (define Pawn-move ( (set-flag pinned? false) mark (pin H-line e w) (pin D1-line ne sw) (pin D2-line se nw) (verify (not-flag? pinned?) ) n (verify empty?) (Pawn-add) (verify (in-zone? third-rank)) n (verify empty?) add ) ) This code prohibits pinned pieces from moving off the attack line. But unlike "Checkmated King", it does not enforce defending to the attack against King. |
Tony Britton (Captain)
New member Username: Captain
Post Number: 16 Registered: 12-2009
| | Posted on Monday, March 08, 2021 - 1:50 pm: | |
Thank You, for the greatly appreciated help. I would have never thought that calling it out like that would have made a difference. I will let you know how it all works out. I will definitely download some more of your games to play and check out your code work. If you have any one you think I should examine, please let me know. |