Ludii Forum
Jump line of pieces as long as at least one piece of type is present - 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: Jump line of pieces as long as at least one piece of type is present (/showthread.php?tid=1480)



Jump line of pieces as long as at least one piece of type is present - AlexanderBrady - 02-23-2023

I am trying to create a code where piece A can jump a line of pieces of types A, B, or C, but only if at least one C is present in the line. Is this possible?

Here is the code I have written, but it only allows A to jump if all pieces in the line are C.
Code:
(move Hop
    (between
        (max (count Rows))
        if:(and (or {
            (is Empty (between))
            ("IsPieceAt" "Soldier" Mover (between))
            ("IsPieceAt" "Shooter" Mover (between))
            ("IsPieceAt" "Base" Mover (between))
            } )
            (>= (count Pieces Mover if:("IsPieceAt" "Base" Mover (between))) 1)
        )
    )
    (to if:(is Empty (to)))
    (then (promote (last To) (piece "Shooter") Mover))
)



RE: Jump line of pieces as long as at least one piece of type is present - Tester001 - 02-27-2023

Do you have a .lud file?, maybe someone can help then.

and

Did you check with the 'Test Ludeme' dialog what the (count Pieces) line really creates as result in various cases?


RE: Jump line of pieces as long as at least one piece of type is present - AlexanderBrady - 02-28-2023

Here is a pastebin with the ludii file:
https://pastebin.com/UmTgzZwM

Ignore the metadata, which is just copied from the Chess Ludeme.

I haven't tried the "Test Ludeme" dialog. I did some testing with the code that I have - it seems to count each "between" space individually.

If I set the minimum count to 0, the "if" statement does nothing (which makes sense). If I set it to 1, it works if and only if every "between" space is the target piece type (not a minimum of 1 of that piece, every "between" space is that piece). If I set it to 2 or more, the movement option is never allowed.


RE: Jump line of pieces as long as at least one piece of type is present - Tester001 - 03-01-2023

Ok, I had a look at it but the   (ahead (from) #1 (directions .. )  line did not compile in my Ludi.player 1.3.10.