Ludii Forum
Using directions in (step) in (sites Distance) - 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: Using directions in (step) in (sites Distance) (/showthread.php?tid=508)



Using directions in (step) in (sites Distance) - Michael - 03-16-2021

Say I want a piece to be able to move to any site reachable by up to 3 steps onto empty cells. This can be done by letting it move to the following region:
Code:
(define "Reachable1"
    (sites Distance
        (step
            (to
                if:(is Empty (to))
            )
        )
        from:(from)
        (range 1 3)
    )
)
But say I want to restrict movement to sites reachable by forwards steps onto empty cells. Then one might think the following would work:
Code:
(define "Reachable2"
    (sites Distance
        (step
            Forwards
            (to
                if:(is Empty (to))
            )
        )
        from:(from)
        (range 1 3)
    )
)
It does not, however. My questions are: 1. Is this supposed to work. 2. If it is not supposed to work, what is the correct approach?

What happens, btw, is that the piece can only be moved 1 step forwards. And if I set the range to, say, (range 2 3), it can not move at all.

Hm.. I just noticed that this only lets me move to sites up to 2 steps away, as if (range 1 3) is not inclusive with regard to upper extent.. But it is supposed to be.


RE: Using directions in (step) in (sites Distance) - Eric Piette - 03-18-2021

Hi,

Depend what you mean by "forwards" here. Because Forward is a relative direction defined according to the facing direction of the piece (or if none, the facing direction of the player) like in Chess for the pawns.
However here, when you call that step move with Forwards and reach some empty sites, these sites does not have any pieces on it, so no facing direction and consequently no directions corresponding to the relative direction Forwards.

Regards,
Eric


RE: Using directions in (step) in (sites Distance) - Michael - 03-18-2021

(03-18-2021, 10:09 AM)Eric Piette Wrote: Hi,

Depend what you mean by "forwards" here. Because Forward is a relative direction defined according to the facing direction of the piece (or if none, the facing direction of the player) like in Chess for the pawns.
However here, when you call that step move with Forwards and reach some empty sites, these sites does not have any pieces on it, so no facing direction and consequently no directions corresponding to the relative direction Forwards.

Regards,
Eric
I want the reachable sites to be computed as if the piece had to actually take the walk, not changing it's direction along the way. So forwards should be the same at all the relevant sites as it is for that piece. Is this possible?


RE: Using directions in (step) in (sites Distance) - Eric Piette - 03-18-2021

Hi,

So what you want here is not really the sites at a specific step distances but the line of sight of a piece right?
If yes, you should use (sites LineOfSight ...)

Regards,
Eric


RE: Using directions in (step) in (sites Distance) - Michael - 03-18-2021

(03-18-2021, 10:24 AM)Eric Piette Wrote: Hi,

So what you want here is not really the sites at a specific step distances but the line of sight of a piece right?
If yes, you should use (sites LineOfSight ...)

Regards,
Eric
No, the piece can change directions at any step. But only between forwards directions. And it cannot change the meaning of forwards, or the fact that it must move forwards. Am I making sense? The destination sites should be the answer to "If this piece, which only steps forwards, were allowed to step up to n steps, where could it land?"


RE: Using directions in (step) in (sites Distance) - Eric Piette - 03-18-2021

Hi,

I am not sure of what you try to do. I think it would be good if you make me an example, in taking a screenshot of a board in using Ludii, then show me in this specific state, where a piece should be able to go.

Regards,
Eric


RE: Using directions in (step) in (sites Distance) - Michael - 03-18-2021

The first attached image shows the to-sites for the following move:
Code:
(move
    (to
        (sites Distance
            (step
                (to if:(is Empty (to)))
            )
            from:(from)
            (range 1 5)
        )
    )
)
These are all the sites that D4 can reach by taking up to 4 steps onto empty sites (let's ignore the strange fact that the range is set to 5, and not 4).

But if D4 was restricted to taking steps in the forward directions, which in this case would be WNW, N and ENE, then the result would be the sites not crossed out in the second image. But what is the Ludii description of that move? I thought it would be:
Code:
(move
    (to
        (sites Distance
            (step
                Forwards
                (to if:(is Empty (to)))
            )
            from:(from)
            (range 1 5)
        )
    )
)
Given, of course that the piece belongs to a player with the north direction.


RE: Using directions in (step) in (sites Distance) - Eric Piette - 03-19-2021

Hi,

Ok so in reality here that's the distance computed with steps using the facing direction of the from site. That makes sense, but that was not implement to be able to keep the facing direction of the piece at from for the others sites. So, I just implemented that small modification and now that works exactly as you expect for that relative direction. Consequently, that should work in the next release with the description in which you use "Forwards".

Regards,
Eric


RE: Using directions in (step) in (sites Distance) - Michael - 03-19-2021

Amazing! Thanks :)

Will conditional directions also work here? In the same sense, I mean, based on (from). In this game, odd stacks move forwards and even stacks backwards.