Ludii Forum
Could we have a who iteration operator - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Suggestions (https://ludii.games/forums/forumdisplay.php?fid=10)
+--- Forum: Ludii Features / Services (https://ludii.games/forums/forumdisplay.php?fid=11)
+--- Thread: Could we have a who iteration operator (/showthread.php?tid=339)



Could we have a who iteration operator - dale walton - 12-17-2020

For multi player games, some moves may cause a need to update all the scores by means of a function, (or possibly to affect other players' pieces in the consequences)

The player iterator is for all the moves of the players and doesn't have its own iterator value, and I don't know how it would affect game flow if used it in a consequence.

I suggest a Who iterator that iterates over players without invoking their moves:

For example: to update the scores of players with pieces in the vicinity of a moved piece:


(forEach Who In:(sites Around (to)) (set Score (who) (count Pieces (who))))


And  maybe also

(forEach Who Team1 (set Score (who) (count Pieces (who))))

i.e iterator for Player roles ...


RE: Could we have a who iteration operator - Eric Piette - 12-17-2020

Hi,

Yes, in reality I was thinking I already did it but apparently not.
I will do it for the next release.

The iterator will be (player) and the ludeme (forEach Player <Moves>).

Regards,
Eric


RE: Could we have a who iteration operator - dale walton - 12-17-2020

Thanks. At least not in the documentation...

I did find a workaround for my specific problem by finding the who for the affected site and using that to update the scores as a specific move consequence.

Another alternative for the particular problem would be if, in the Meta section, a (set Score Each <int>) were possible where <int> is a function that is executed to update scores at the end of each move / turn / player-change / phase or game as applicable... in a way similar to how (player 2 <moves>) handles movement.

That idea is a bit specific, and I don't know if it is a direction you want to move toward or not...