Ludii Forum
Forward movement not enforced - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Game Problems (https://ludii.games/forums/forumdisplay.php?fid=17)
+--- Thread: Forward movement not enforced (/showthread.php?tid=575)



Forward movement not enforced - Michael - 05-26-2021

I have to apologize for not having made a minimal lud with the relevant issue. But I'm guessing this has to do with the recent update to (step). In the attached lud there is a forward moving stack that is allowed to move backwards. I cannot see how. Any ideas?

The to-region of the move is defined like this:
Code:
(define "EmptyInRange"
    (sites Distance
        (step
            (if
                (is Odd ("StackSize" (from)))
                Forwards
                Backwards
            )
            (to
                if:(= 0 ("StackSize" (to)))
            )
        )
        from:(from)
        (range 1 ("StackSize" (from)))
    )
)
If the stack is odd, the to-sites should be in front of the stack, if it is even they should be behind it. But they are both, as illustrated in the attached image and the attached trial.


RE: Forward movement not enforced - Eric Piette - 05-27-2021

Hi,

Ok, I looked at this issue, but this is not a bug, just a problem with the description.

The computation of the ludeme (sites Distance ...) is here described with a step move. This step move is evaluated at each site reached during the computation of the result of the ludeme (sites Distance ...). BUT here the direction of the step move is defined with

Code:
(if
    (is Odd ("StackSize" (from)))
    Forwards
    Backwards
)


Consequently, for the step computation for the stack of size 3 on your trial, you got a Backwards move. But after when the computation is done again on the first site reached by that step, the 3 sites corresponding to the first Backward move is empty. Consequently, for these sites, you got a Forwards move (because 0 is even to be clear).
So to sum up, here you are computing the sites at a distance of step moves which can alternate between backward and forward moves, which is obviously not something you want.

To avoid that, you just have to check the (from) site outside of the (sites Distance ...) then to keep the direction during all the computation of this ludeme for the step move.
Here is the code (which would be shorter if you use a define for the (sites Distance ...) part)

Code:
(if
(is Odd ("StackSize" (from)))
    (sites Distance
        (step
            Forwards
            (to
                if:(= 0 ("StackSize" (to)))
            )
        )
        from:(from)
        (range 1 ("StackSize" (from)))
    )
    (sites Distance
        (step
            Backwards
            (to
                if:(= 0 ("StackSize" (to)))
            )
        )
        from:(from)
        (range 1 ("StackSize" (from)))
    )
)

Eric


RE: Forward movement not enforced - Michael - 05-27-2021

Thank you so much! That's really helpful!

Could you perhaps also tell me why the 3-stack in the example I gave can move up to 2 steps (after your fix) even though the range is (range 1 ("StackSize" (from)))?


RE: Forward movement not enforced - Eric Piette - 05-28-2021

Hi,

I guess you should just have (+ 1 ...) to move at that distance? I think here the range is [a;b[ for distance with step moves.

Regards,
Eric