Ludii Forum
Getting first element of Integer array - Printable Version

+- Ludii Forum (
+-- Forum: Questions (
+--- Forum: About the Ludii Grammar (
+--- Thread: Getting first element of Integer array (/showthread.php?tid=539)

Getting first element of Integer array - fbarbe - 04-11-2021


I was wondering if there is a simple way of getting the first element of an Integer array in Ludii.

I am trying to write the game "Shobu", and would like to do the following:

(move Select
    (from (site))
            steps:(count Steps (last From) (last To))
            (directions Cell from:(last From) to:(last To)) //FIXME: this should be a direction, not array of directions
        if:(is In (to) ("CurrentBoard" (from))) //TODO: piece can only push ONE stone, of the opposite colour

the issue with the above code is that the (ahead) ludeme takes a single direction, and the (directions) returns an array of directions (with only one element in this case).

I had a quick look at the Ludii Language Reference but could not find anything.

I have also attached my progress for Shobu so far. Feel free to provide feedback/advice, as I am pretty much stuck (I wrote FIXMEs and TODOs ).
The rulebook can be found here:
What's tricky for me is that it would make sense to use the "(push" ludeme for this game, but that ludeme only appears in one game in the ludii library (Pushing Me XO), so it's hard to find examples.

Kind Regards,

RE: Getting first element of Integer array - Eric Piette - 04-12-2021


Concerning Shobu itself, you have my answer by mail :)

For getting a specific site of a region you have the ludeme (regionSite ...)
If you want to do that for an IntArrayFunction you have to convert you regionFunction to an IntArrayFunction first with (sites <IntArrayFunction>)