Ludii Forum
(count Groups / (count Regions - Printable Version

+- Ludii Forum (
+-- Forum: Suggestions (
+--- Forum: Ludii Features / Services (
+--- Thread: (count Groups / (count Regions (/showthread.php?tid=1522)

(count Groups / (count Regions - dale walton - 03-27-2023

The  count Groups counts the number of piece groups within the restrictions on to (the default condition of is Occupied (to) does not get overridden by the if: contents.  Perhaps this is for backward compatibility.

It might be appropriate to create a new parameter instead:

(count Regions <Cells> <Adjacent> within:<region> excludeIf:<boolean>) This would give the number of disjoint regions within a region, not counting regions that met the boolean condition. Iterators  (sites).

eg: Score a point for each region that each friendly group divides the board into, excluding fully surrounded regions:
(set Score Mover 0
  (forEach Group
   if:(is Mover (who at:(to)))
   (addScore Mover
    (count Regions
     within:(sites Around (sites))  // this (sites) refers to Group iterator above
     excludeIf:(= 0 (size Array (array (intersection (sites) (sites Outer)))))  // this (sites) refers to sites in each disjoint sub-region

Being able to use (sites) for the sub-region exclusion would be more intuitive than  using (to) as (to) conditions would likey be misunderstood to be exclusions of sites in the sub-region, rather than exclusions of the entire sub-region in which they occurred. - as well as being much more difficult to formulate for the given example.