Ludii Forum
Do a non-decision before a decision - 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: Do a non-decision before a decision (/showthread.php?tid=600)



Do a non-decision before a decision - slimy_asparagus - 06-07-2021

I am looking for a way to do a non-decision move before or-clause of decision moves.

I feel like I have previously mastered the core decision paradigm in Ludii.

Code:
(play
        (if "SameTurn"
            (priority {

.....
.....      a series of decision moves required/allowed by the previous decision move
.....
.....
                        })
                        (or {
.....
.....      a selection of alternative initial decision moves
.....
                        })
                )
)

The problem I am hitting is that some of those decision moves need to register that they were done in the game state until we get back to our next initial decision move. I am using the "value" in the effected pieces to remember this.

So for the effected pieces I set the value when they are placed.
If the state is triggered then I set the value when and where appropriate.
So what I am struggling to do is to reset the value to its initial state just before that (or .... ) clause, so that it is fresh everytime a player starts their turn.

I don't believe I can use "Pending" because a turn could consist of theoretically 8 moves.
The (or ....) ludeme has an optional (then) clause. That is almost what I want, except that I need my non-decision to trigger just before the (or...) not after.

I know there is an (apply....) ludeme but that would be very difficult to fit across all the different cases.

I have tried to use a (do next:)               Ludeme. That compiles but does not seem to work. I don't know why.

If I use (and .... (then....)), then it compiles but says you have to pass immediately.
Similarly for (append ... (then...)).  Though I do see why these latter ones did not work.

Hmm, okay I have an idea. The (if.. ) ludeme has an optional (then clause). Maybe I could use that to reset the flag for the next player.

So I move the reset from the beginning of a player's turn to the end of the previous player's turn. That sounds worth trying.

Nope that won't work for the same reason Pending won't. I can't see anyway I could check if it was the end of the turn.OR at least it would be as difficult as trying to squeeze (apply ...) into every bit of code.

So what would be really great, is if the (or...) ludeme could have an optional (apply ....) clause like it has a (then ...) clause.

So we could say "Do one of these N moves, but whichever one you choose, do P first and Q afterwards." So we can already say "do Q afterwards". As far as I can see there is no way of saying "do P first".


RE: Do a non-decision before a decision - Eric Piette - 06-08-2021

Hi,

What you are asking here is the (do ...) ludeme.
I know you said that did not work, but you did not explain your case.
Can you make a simple and short .lud showing that does not work?

Because the do ludeme is used in more than 200 games and all are working. For example, 100% of our dice games use that to roll the dice before describing the decision move.

Regards,
Eric


RE: Do a non-decision before a decision - slimy_asparagus - 06-08-2021

(06-08-2021, 05:38 AM)Eric Piette Wrote: Hi,

What you are asking here is the (do ...) ludeme.
I know you said that did not work, but you did not explain your case.
Can you make a simple and short .lud showing that does not work?

Because the do ludeme is used in more than 200 games and all are working. For example, 100% of our dice games use that to roll the dice before describing the decision move.

Regards,
Eric
Okay I am sure I can come up with a more tractable example.It may take me a while though.


RE: Do a non-decision before a decision - slimy_asparagus - 06-08-2021

Okay I have formulated a simple game idea where I can test whether I can partially reset a game state at the start of the player's turn. However I have hit an issue, before I have got as far as needing a (do.....) ludeme.


I have a 9x9 board with an initial board somewhat full of pieces. At the start of a player's turn each piece has its range reset to 1.
A piece moves and captures like  a queen but restricted to its range. Each time a piece captures that piece gets an increment to its range, and also the player gets another go. In addition pieces with a range greater than 1, protect pieces within their range.

So far in my implementation I have only managed to get the range and its increment working. I have not yet attempted the extra moves, the reset of ranges to 1 or the protective features.

Also I could not find a way to update the range directly (and to get it to only update if there is a capture). I had to store it temporarily in (var).

So my major problem is that in the attached trial the piece with range 5 cannot successfully capture anything. It just hangs there.

Also when I test (var) in the Test dialog it is always 0, even though I can see it is being updated.

Also when I try to test this code in the TEst Dialog I don't get the correct results:

Code:
(forEach (sites Occupied by:Next) if:(< 1 (state at:(site))))

So I have managed to do the (do.....) ludeme (after limiting the state to maximum 4) and in this case it works (Range2). So I shall need to revisit my initial issue. I would appreciate some insight to the issues I have had with this experiment.


RE: Do a non-decision before a decision - slimy_asparagus - 06-08-2021

Okay I think I have resolved the initial issue. I can see what is going on a trial much better than any other method.

Also at least on this occasion, I can see that the reason the Test Ludeme dialog mislead me was that I do actually need to take a go to have the reset happen.

However the issues I was having with the Range experiment still puzzle me, and they look reminiscent of issues I have come across elsewhere. I may not have reported them though. So I would really appreciate an answer to those questions.


RE: Do a non-decision before a decision - Eric Piette - 06-10-2021

Hi,

Should I look Range2 or Range1 now? The trial is for which one?
And you asked many questions, but I am not sure which ones I am supposed to answer now? The one with updating the range in case of capture? Or something else?

Regards,
Eric


RE: Do a non-decision before a decision - slimy_asparagus - 06-10-2021

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

Should I look Range2 or Range1 now? The trial is for which one?
And you asked many questions, but I am not sure which ones I am supposed to answer now? The one with updating the range in case of capture? Or something else?

Regards,
Eric
Eric,

The clearest bug is in Range.lud with the trial ranger.trl. You have a Black piece with state 5 and when you try to capture something with that piece it goes wrong.


I have verified that that is still the case this morning. I had enormous problems verifying this. I eventually realized that the trial file was pointing to my working version of Range.lud which has a work-around. So in my case I had to repoint the trial file to the downloaded .lud.

I say I have verified it but I can see a new detail. Previously I noticed that the state 5 piece would just hang over a capture. Then I would move it back. Today I noticed that if I give it enough time the state 5 piece seems to disappear eventually.

I have not been able to reproduce the other issues. I am having other issues but those are under investigation.

Thanks for your attention.

Nicholas