Ludii Forum
(priority) - 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: (priority) (/showthread.php?tid=308)



(priority) - Michael - 12-01-2020

I don't think I understand how (priority) works. I thought it was like this:
(priority (if this move is legal, you must do this, otherwise) (you may do this))

But it doesn't seem to work that way. In my game, I have the following:
Code:
        (play
            (priority
                (do
                    (or {
                        (forEach Piece ("MoveZeroStack") Neutral top:true)
                        (forEach Piece ("MoveWholeStack") Mover top:true)
                        (forEach Piece ("MoveStackPart") Mover top:true)
                    })
                    ifAfterwards:(or {
                        ("Capturable" NNW)
                        ("Capturable" W)
                        ("Capturable" SSW)
                        ("Capturable" SSE)
                        ("Capturable" E)
                        ("Capturable" NNE)
                    })
                )
                (or {
                    (forEach Piece ("MoveZeroStack") Neutral top:true)
                    (forEach Piece ("MoveWholeStack") Mover top:true)
                    (forEach Piece ("MoveStackPart") Mover top:true)
                })
            )
        )
Or, in essence:
Code:
        (play
            (priority
                (do
                    <move>
                    ifAfterwards:<boolean>
                )
                <move>
            )
        )
I would think that the result is that, if you can <move> such that <boolean> becomes true, you must. Otherwise there is no restriction on <move>.

Since I obviously have misunderstood, my question is both (1) what is my mistake, and (2) how do I get the intended effect, then?

I'm sorry that I don't have a simple test.lud. I'm hoping it is possible to answer my question based on the description I have given above.


RE: (priority) - Eric Piette - 12-01-2020

Hi,

The ludeme priority has a list of moves ludemes in entry. The first one with at least one legal move in the list is returned.

(priority {
<MoveLudeme1>
<MoveLudeme2>
<MoveLudeme3>
})

If MoveLudeme1 has no legal moves but MoveLudeme2 and MoveLudeme3 have legal moves.
This ludeme will return the list of legal moves corresponding to MoveLudeme2.

Regards,
Eric


RE: (priority) - Michael - 12-01-2020

Thanks for that explanation. Since I only have two move ludemes in (priority) I take it that the {}-brackets are not necessary. Then things should work as I expected, right? If (do …) is possible you must make that move. Othewise you may make the other. But it doesn’t seem to work. I can’t figure out why.


RE: (priority) - Eric Piette - 12-01-2020

Do you have a trial for me working with the .lud you put here, in which you think the second move in your priority should be used rather than the do one?

Regards,
Eric


RE: (priority) - Michael - 12-01-2020

I think I have an idea about what my mistake is. I’ll report back later.


RE: (priority) - Michael - 12-01-2020

(12-01-2020, 09:00 AM)Michael Wrote: I think I have an idea about what my mistake is. I’ll report back later.
Yes, this was totally my fault. I forgot to pull the actual capturing out of the moves and into the (then) of (priority). So ifAfterwards was checking if a capture could be made after it had already been made..

Thanks for yor help!