![]() |
Cycling through opponent's groups - 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: Cycling through opponent's groups (/showthread.php?tid=674) |
Cycling through opponent's groups - dale walton - 08-15-2021 I have a new game in which a player places a piece next to each of his opponent's groups It would be natural to do a (forEach Group ... (move Add (to (sites Around (sites))) ) but I don't see a parameter for specifying the owner of the iterated groups. How can this be done in the if:() clause of forEach Group? - or is a language extension required? RE: Cycling through opponent's groups - Michael - 08-15-2021 Isn't that just if:(= (next) (who at:(to)))? RE: Cycling through opponent's groups - dale walton - 08-15-2021 i.e. (forEach Group if:(= (next) (who at:(to))) (move Add (to (sites Around (sites))) ) Re : your question. I don't know the answer, that is why I am asking. I don't see the answer in the documentation which doesn't say what a group is or how it is selected. (is a group simply a region defined by the boolean? If so,there must be a default if not if clause is specified which is not given in the documentation, but can be overridden... can the groups in forEach Group have overlapping elements?) I had assumed that groups were based on mover's pieces. My guess was if it was more general, it would need something like if:(all (sites) if:(is Next (who at:(site)))) I will give yours a try first. BTW why is the iterator "to"? Where is this use of "to" documented? Should my above attempt be if:(all (sites) if:(is Next (who at:(to)))) ? Sorry for so many questions... -------------------------------------------------------\ OK I see a similar thread called "forEach Group if:" and am studying it. Note my purpose is to achieve a turn with many placements, so the above was to simple an approach... RE: Cycling through opponent's groups - Eric Piette - 08-18-2021 Hi, As a quick answer, yes you have to use the boolean condition to iterate through each group. That's going to iterate all the groups checking that condition. Regards, Eric |