Ludii Forum
Counting instances of "Disc" at a site - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Questions (https://ludii.games/forums/forumdisplay.php?fid=13)
+--- Forum: About the Ludii Grammar (https://ludii.games/forums/forumdisplay.php?fid=15)
+--- Thread: Counting instances of "Disc" at a site (/showthread.php?tid=510)



Counting instances of "Disc" at a site - Michael - 03-17-2021

I have been trying to figure out how to count the number of discs in a stack that may (or may not) have a tile at the bottom (level 0).

Given that I have made sure that the tiles have component id 1 and 2, and the discs 3 and 4, it seems like the following should work:
Code:
(count Stack 
    FromTop
    at:<int>
    stop:(> 3 (what at:(to)))
)
I thought: It starts counting from the top, and if it reaches a component with id 2 or less, it stops counting. But it returns 0 when I have a disc on top of a tile.

So I tried this:
Code:
(count Stack 
    at:<int>
    if:(< 2 (what at:(to)))
)
I was thinking it might count all the pieces in the stack that have id 3 or more. But again it simply returns 0 when there is a tile in the stack.

I the tried:
Code:
(count Pieces
    "Disc"
    in:(sites {<int>})
)
That returns 0 no matter what I try to do. I tried "Disc1", but that didn't do anything.

So now I'm asking: How do I count the number of discs in a stack that may or may not have a tile at level 0?


RE: Counting instances of "Disc" at a site - Eric Piette - 03-18-2021

Hi,

That code here is counting the number of Disc owned by the mover in the stack at site 0. I think that's what you are looking for.

Code:
(count Stack
      at:0
      if:(= (id "Disc" Mover) (what at:(to) level:(level)))
)

Regards,
Eric