Ludii Forum
Acting on a Line of components - Printable Version

+- Ludii Forum (
+-- Forum: Questions (
+--- Forum: About the Ludii Grammar (
+--- Thread: Acting on a Line of components (/showthread.php?tid=106)

Acting on a Line of components - ccxvii - 08-04-2020

I'm trying to implement Yinsh. I can't quite figure out how to act on the detected line of components.

I can detect a line anywhere on the board with some difficulty:

(if (is Line 5 throughAny:(sites Occupied by:P1) what:(id "Disc1"))

The throughAny argument has to be there, or it will only detect lines going through the (last To) location by my experimentation (again, a lack of source code to the core Ludii ludemes, and the rather bare bones documentation means a lot of trial and error in figuring these things out, and this seems to be uncharted territory so the existing game files aren't much help). Puzzlingly enough, throughAny:(sites All) doesn't work!

Now for the trickier bit -- I have to remove the pieces that form the line. Is there any way to get a list of the sites that form the line for passing to (remove)?

I've tried this to no effect (thinking I could filter out all sites that have a line of 5 going through them).

(remove (forEach (sites Occupied by:P1) if:(is Line 5 through:(site) what:(id "Disc1"))))

P.S. Can you make "Disable Smilies" the default for the forum, given how often Ludii code is quoted here.

RE: Acting on a Line of components - MatthewStephenson - 08-04-2020

Thanks for the suggestion!
"Disable Smiles" should now be selected by default.

RE: Acting on a Line of components - cambolbro - 08-04-2020


Your suggested approach makes sense:

     (remove (forEach (sites Occupied by:P1) if:(is Line 5 through:(site) what:(id "Disc1"))))

but maybe phrased differently, e.g. 

     (forEach Site (sites Occupied by:Mover) if:(is Line 5 through:(site)) (remove (site)))

assuming that the removals are done at the end of the turn. If not, then the (forEach Site ...) could set a pending value for the relevant sites and a subsequent move could be made to empty all pending sites.

Or maybe a formulation of (forEach Piece ...)?

Eric who wrote that code is back next week, he may be able to advise further.