10-27-2020, 01:26 PM
This question is meant to replace the one asked here. I'm having issues with the new ludeme (forEach Group). I have made a simpler version of what I'm trying to do which should illustrate my issue a bit better.
In the attached game the score is calculated when a pass is followed by a pass. A player's score is supposed to be the sum of the value of of each of that player's groups, and the value of a group is the square of the number of stones in it. So a size 1 group has value 1, a size 2 group has the value 4, and so on (|3|=>9, |4|=>16, |5|=>25 …). If I have 2 groups of size 5, my score should be (+ (* 5 5) (* 5 5)). If I had understood the new ludeme correctly, the formula should be
But this does not give the expected result. I expected that this code would go through each group and add to the relevant player's score the square of the number of that player's stones in that group (so 0 is added for each group that belongs to the other player).
I'm wondering what it is I am misunderstanding.
In the attached game the score is calculated when a pass is followed by a pass. A player's score is supposed to be the sum of the value of of each of that player's groups, and the value of a group is the square of the number of stones in it. So a size 1 group has value 1, a size 2 group has the value 4, and so on (|3|=>9, |4|=>16, |5|=>25 …). If I have 2 groups of size 5, my score should be (+ (* 5 5) (* 5 5)). If I had understood the new ludeme correctly, the formula should be
Code:
(define "CalculateScore"
(forEach Group Orthogonal if:true
(and
(addScore P1
(*
(count Sites
in:(intersection (sites) (sites Occupied by:P1))
)
(count Sites
in:(intersection (sites) (sites Occupied by:P1))
)
)
)
(addScore P2
(*
(count Sites
in:(intersection (sites) (sites Occupied by:P2))
)
(count Sites
in:(intersection (sites) (sites Occupied by:P2))
)
)
)
)
)
)
I'm wondering what it is I am misunderstanding.