| Author |
Message |
Bruce Dickey (Bruce_D)
| | Posted on Sunday, April 16, 2006 - 10:57 pm: | |
Hi, complete newbie here. I have created a game on a square grid in which the winning condition is that no friendly piece be adjacent to any other. Everything is working except the win condition. From the documentation it would seem at first that something like (win-condition (Red White) (relative-config Ball ; not working n (not Ball) e (not Ball) s (not Ball) s (not Ball) w (not Ball) w (not Ball) n (not Ball) n (not Ball) ) ) ; check all surrounding squares for no piece of the same player would work, but it does not. Any suggestions? Do I have to do something special at the board edges? Thanks, Bruce |
Mats W (Kålroten)
| | Posted on Monday, April 17, 2006 - 12:31 pm: | |
If that doesn't work, then you could perhaps verify, when making moves, that there is at least one friend adjacent to the piece. This means that if there are no more pieces that are adjacent to each other, then the player is stalemated. But you could set stalemate to win-condition. Mats |
Bruce Dickey (Bruce_D)
| | Posted on Tuesday, April 18, 2006 - 9:20 pm: | |
Thanks, Mats. The verify would have to be AFTER the add so that the move can be made, if I understand correctly -- I'll do some more reading of the reference and examples since I don't know at the moment how to do this. Last night I mocked up a solution using absolute-config for each win position after writing a Python program to generate the win positions, but that is neither elegant nor efficient. |
Mats W (Kålroten)
| | Posted on Wednesday, April 19, 2006 - 12:18 am: | |
No, the verify statement should be first. But this only works if moves of isolated pieces are disallowed. If you can move an isolated piece then my proposal doesn't work. So I realize now that my idea was not so clever after all. But you could perhaps create a variant game where isolated pieces can't move. Then you only need to write, for instance, "(verify not-friend? n) (verify not-friend? s)" etc., and set stalemated to win-condition. But I don't know why your relative-config doesn't work. (Karl? Larry?) Mats |
Bruce Dickey (Bruce_D)
| | Posted on Tuesday, April 25, 2006 - 9:26 pm: | |
Well, I "finished" my first game in which the win condition is that no friendly piece be adjacent to any other by using absolute-config and listing ALL the possible win positions. Quite unwiedly on the small board that I used. Now I'm working on a large-board variant and this approach will be unfeasible. Relative-config is so tantalizing. Can someone point out what is wrong with my code in original post? Thanks a ton! Bruce |
Mats W (Kålroten)
| | Posted on Wednesday, April 26, 2006 - 1:16 pm: | |
Try experimenting with (opponent [piece-type])) or ((any-owner [piece-type])) within the relative-config clause, or perhaps you must have separate win-conditions for Red and White. Just suggestions. |
Karl Scherer (Karl)
| | Posted on Friday, April 28, 2006 - 5:14 pm: | |
You can also - in your program - scan the board for this (win) condition and - if met - create a special piece on a special position, whose existenc is then simply checked with an absolute-config statement in your win-condition. I have used this method a lot. It often is the only way to do it if the zillions win-condition structure does not provide help. |
Bruce Dickey (Bruce_D)
| | Posted on Wednesday, May 03, 2006 - 11:53 pm: | |
Woo-hoo! The following is working! Reversed the logic so as to not use (not piece). Don't know if that is what the problem was, though... (win-condition (Player1 Player2) ; No piece has a friendly piece adjacent (not (or (relative-config piece n piece) (relative-config piece ne piece) (relative-config piece e piece) (relative-config piece se piece) (relative-config piece s piece) (relative-config piece sw piece) (relative-config piece w piece) (relative-config piece nw piece) ) ) ) Thanks Mats and Karl, Bruce |
|