Ludii Forum
Counting pieces in a stack - 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 pieces in a stack (/showthread.php?tid=870)



Counting pieces in a stack - dale walton - 03-21-2022

I want to know the number (not position) of a given player's pieces in a stack.

(count Stack seems to give the position.

(count Pieces  only allows "in:<region>",  not  at:<site>

How do I do this?

The exact purpose is part of code to count the number of stacks that have a majority of a given player's pieces for scoring.


RE: Counting pieces in a stack - Michael - 03-21-2022

(size Stack …)

Edit: But it should be possible to use (count Stack) as well. We used it for Seesaw, because we needed to ignore the tile at the bottom of the stack.

I think this should work:
Code:
(define "CountInStack"
    (count Stack
        at:#1
        if:(= #2 (who at:(to) level:(level)))
    )
)



RE: Counting pieces in a stack - dale walton - 03-22-2022

(size Stack ...) is what I was looking for - Thanks.