Ludii Forum
Integer function wanted - 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: Integer function wanted (/showthread.php?tid=328)



Integer function wanted - Michael - 12-10-2020

I'm working on implementing a new capture mechanism that needs to know the number of contiguous same-colored pieces from the top of a stack. An example: If a stack contains (from the top down) "Disc1", "Disc1", "Disc2, "Disc1", the function should return 2, because there are 2 contiguous pieces of the top color.

Here is a suggestion for the syntax:
(size Stack [<siteType>] ([in:<region>] | [at:<int>]) [stop:<boolean>])
• [stop:<boolean>]: Stops counting if a piece meets the condition. Pieces are counted from the top of the stack and the piece meeting the condition is not counted.

I'm not sure how one should reference the piece, but "(to)" can work as long as it only ever refers to the value it has inside "stop:". Example: 
Code:
(size Stack
    at:(to)
    stop:(!= (mover) (to))
)
This would return the number of pieces belonging to the mover from the top of the stack , and the value of the two (to)s should be independent.

Is it possible to implement something like this? (It would make me very happy.)


RE: Integer function wanted - Michael - 12-14-2020

I just wanted to say that I am fine living without this feature. And I doubt many others will have use of it.


RE: Integer function wanted - Eric Piette - 12-14-2020

Hi,

Ok thanks.
However I will probably add something to be able to do that easily :)

Regards,
Eric


RE: Integer function wanted - Eric Piette - 12-15-2020

Hi,

Ok in case you still need it for something else that will be possible with the ludeme
(count Stack ...)

e.g.

Code:
(count Stack
   FromTop
   at:0
   if:(= (id "Ball" P1) (what at:(to) level:(level)))  
   stop:(= (id "Ball" P2) (what at:(to) level:(level)))
)

That will count from the top of the stack at site 0 in counting the ball owned by P1 until a ball owned by P2 is reached.

Will be available in version 1.1.11

Regards,
Eric