12-10-2020, 04:12 AM
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:
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.)
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))
)
Is it possible to implement something like this? (It would make me very happy.)