10-18-2020, 05:53 PM
(This post was last modified: 10-18-2020, 05:56 PM by Eric Piette.)
Hi Alek,
Yes you can detect that pattern with alternating pieces with our new ludeme (is Pattern ...)
For example let's say you want to detect your square pattern and the 'O' is the "Ball" of P1 and the 'X' is the "Ball" of P2.
You can detect it with
(is Pattern {F R F R F} whats:{(id "Ball" P1) (id "Ball" P2)})
Just be careful, the pattern will start the detection from the last site played and will check for a pattern OXOX here.
so if you want to detect a pattern XOXO, you will have to swap the "whats" parameter like that:
(is Pattern {F R F R F} whats:{(id "Ball" P2) (id "Ball" P1)})
A simple (if ...) on the last move played for example is enough to have the two cases in the same .lud if you need to check that.
Another possibility if each player has only one piece (and the game has only 2 players and you check from the last site played) you can do something like that
(is Pattern {F R F R F} whats:{(mover) (next)}) to avoid the If test and being a little bit more efficient.
Regards,
Eric
Yes you can detect that pattern with alternating pieces with our new ludeme (is Pattern ...)
For example let's say you want to detect your square pattern and the 'O' is the "Ball" of P1 and the 'X' is the "Ball" of P2.
You can detect it with
(is Pattern {F R F R F} whats:{(id "Ball" P1) (id "Ball" P2)})
Just be careful, the pattern will start the detection from the last site played and will check for a pattern OXOX here.
so if you want to detect a pattern XOXO, you will have to swap the "whats" parameter like that:
(is Pattern {F R F R F} whats:{(id "Ball" P2) (id "Ball" P1)})
A simple (if ...) on the last move played for example is enough to have the two cases in the same .lud if you need to check that.
Another possibility if each player has only one piece (and the game has only 2 players and you check from the last site played) you can do something like that
(is Pattern {F R F R F} whats:{(mover) (next)}) to avoid the If test and being a little bit more efficient.
Regards,
Eric