Ludii Forum
Setting rotation between each step when counting step-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: Setting rotation between each step when counting step-distance (/showthread.php?tid=625)



Setting rotation between each step when counting step-distance - Michael - 07-01-2021

Say I have a piece that is oriented eastward. Can I use (sites Distance) to get all sites reachable by that piece given a restriction that, after each step, it may turn to the right (clockwise) or keep it's orientation? So I get all sites reachable by a piece that cannot turn to the left, basically. I'm specifically thinking of turning as adding 1 to its rotation, then do mod the number of orientations.

Edit: I just found out what I should have tried before asking. I must try to set the rotation inside (step (then …)). I still haven't tried it, but I'm in the process of understanding these things now.


RE: Setting rotation between each step when counting step-distance - Eric Piette - 07-05-2021

Hi,

When you will try that, tell us if that's going to work, I never tried that so I can't be sure.

Regards,
Eric


RE: Setting rotation between each step when counting step-distance - Michael - 07-05-2021

I can't get rotations to work at all.. I take it one has to use the direction "Rotational", but I can't get it to work.

In the attached .lud, I tried to place a disc with rotation:1, but it doesn't even show up. I also tried to set rotation after adding the piece in-game (not in the start-rules) and also inside (apply) in (move), but nothing seems to work.. What am I doing wrong?


RE: Setting rotation between each step when counting step-distance - Eric Piette - 07-06-2021

Hi,

Rotational corresponds to the directions used in a wheel board (Out In CW and CCW). They do not have to be used for the directions referring to the rotation state.

For this, you should just use the usual relative direction such Forward, FR or FL and they will be modified according to the rotation state of the piece (0 corresponding to the first direction in each tiling, for square tiling that's North).
For a good example, I advise you to look at Ploy.lud using that.

Regards,
Eric


RE: Setting rotation between each step when counting step-distance - Michael - 07-06-2021

Thanks! Thats very useful. I still think there is an issue with rotations, though. In the attached .lud, there seems to be two issues:

1: Even though the range is set to (range 1 Infinity), I am only able to step 1 cell ahead when I use the direction Forward.
2: If I set the rotation of a piece to 0, it is unable to move. It seems the rotations go from 1–6 (on this hex-graph), and wrap around so 7 is equivalent to 1, and so on. That's not what the documentation says, though.

Edit to add 3: When the rotation is set to a positive number, the piece goes invisible on my mac..


RE: Setting rotation between each step when counting step-distance - Eric Piette - 07-09-2021

Hi,

I just tested them and the rotations are working.

However, in your .lud file you are not defining the facing direction of the piece, so by default, this direction is N.
But in this hex tiling, the direction N is not existing, consequently, the rotations of a non-supported direction are wrong.
To avoid that, you just need to set the facing direction of the piece to whatever you want rotation:0 to correspond.
Here for example, I set this direction to NNE, if you use that in your game, you will see each piece is stepping in the expected rotated direction (according to NNE).


Code:
(piece "Disc" Each NNE
    (move Step
        Forward
        (to if:(is Empty (to)))
    )
)


Concerning your .lud description with the (sites Distance ....), I also tried it. The rotation is taking into account for the first step move, but after that, only the forward direction of the piece (without rotation) is used for the rest of the steps of the ludeme. So this is probably not doing what you expect here.
I am going to look if I can keep the initial rotation state of the "from" site for the rest of the computation.

Regards,
Eric


RE: Setting rotation between each step when counting step-distance - Eric Piette - 07-09-2021

Hi,

Ok, I can easily keep the rotation of the from site, I will add that code to dev for the next release.
I am also going to look if by any chance the rotation state can be also updated by the step move as you wished.

Regards,
Eric


RE: Setting rotation between each step when counting step-distance - Michael - 07-09-2021

Thank you so much for this, Eric!


RE: Setting rotation between each step when counting step-distance - Eric Piette - 07-09-2021

Hi,

Ok, that's working but I had to add a new optional parameter newRotation to the ludeme (sites Distance ...) so that will be available with the next release.


This new parameter is a function that you have to write which is using the iterator (value) to correspond to the rotation of the previous step and the result of this function is the new rotation state of the site reached by this previous step. Example (adapted from your original file):

Code:
(sites Distance
       (step
           Forward
            (to if:(is Empty (to)))
        )
        newRotation:(+ (value) 1)
         from:(from)
        (range 1 Infinity)
)

This example is stepping Forward according to the initial rotation of the piece and at each step, the rotation increases by 1.

So for an initial rotation of 3 and a facing direction NNE for the white piece, the legal moves of that piece are in red in the attachment file.

I assume that's all that you need for your request :)
All of that will be in the next release.

Regards,
Eric