Ludii Forum
How are duplicate values handled in (remember Values <int>)? - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Ludii Player Problems (https://ludii.games/forums/forumdisplay.php?fid=6)
+--- Thread: How are duplicate values handled in (remember Values <int>)? (/showthread.php?tid=299)

Pages: 1 2


How are duplicate values handled in (remember Values <int>)? - dale walton - 11-28-2020

I  was adding a persistent value 1 as a flag using (remember Value 1) and later removing it with  (forget Value 1)

I tried checking to see if my flag was (un)set with

(not (is In 1 (values Remembered)))

and also with

(= 0 (size Array (values Remembered)))

Ultimately, my logic was kicking in after multiple forgets,

(ie after several consecutive moves that contained a (forget Value 1), the tests above turned positive, but not after the first forget.)


so I was wondering whether this means the same value gets remembered multiple times.

If so, it is not what I expected for an unindexed array in which values can only be deleted by referring to them by value. - but maybe this is intended behavior?

If there are multiple instances, is it an ordered list of some sort?  FIFO / FILO / value size / other?

If this is intended, can there be a (remember Unique Value 1) syntax to avoid duplication?


Also please clarify the scope (eg whole game, into next turn, current turn, into next move (regardless of turn) move, current move ...) for these values - I am assuming the whole game since they require a forget.)

Also clarify for the scope for the new (set Var "Name" <int>) values -- and how and if they differ in scope from the unnamed (var) (if just into the next move, can the scope be extended by copying the value to itself?


RE: How are duplicate values handled in (remember Values <int>)? - Eric Piette - 11-30-2020

Hi,

Yes if you "remember" many times the same value, that value will be stored many times in the list of remembered values.
I like that idea "(remember Value 1 unique:true)" and that would make sense to add it, so I will, thanks for the suggestion.

The new values are always added at the end of the list, but that's important, the order of these values is not accessible through the ludemes.

If you activate the Dev option (Preferences --> advanced --> Developer options), and then on the "Developer menu", you click on "More Developer options" you can see the current stored "remembered" values in the order they are stored.
Just be careful, that frame is not updating if you continue to make moves in the game (you will have to close that frame and to open it again to see the difference).

I am not sure to understand the two last questions in your message.

Regards,
Eric


RE: How are duplicate values handled in (remember Values <int>)? - dale walton - 11-30-2020

Thanks for clarifying how remember works.

The other two questions are about how long the values persist: for (remember... I assume it is indefinitely until they are forgotten.

For (set Var <int>) i remember mention that it persists just within one move and into that move's (then clause -- is that correct? Can you clarify exactly when the value is released?

With the new named (set Var "string" <int>) are the rules the same, or do they persist until set again. Can they be set in (start ... as well as (play ...
Further, what happens if a value is tested before it is set?
-----------------------
This raises the questions
How do operators on values/sets-of-values react to null sets and null values that might occur during evaluation eg counting the distance in steps between two sites from a null list, or where one is off the board, or as in (sites LineOfSite Piece). or finding a list of sites at distance -1 (not found), etc...

eg are any of these allowed? Whether allowed or not, are any true, are any false, any null, any runtime error, any compiler error:
(= <null> 1)
(= <null> 0)
(= <null> -1)
(= 1 <null>)
(= 0 <null>)
(= -1 <null>)
(= <null> <null>)
(!= <null> 1)
(!= <null> 0)
(!= <null> -1)
(!= 1 <null>)
(!= 0 <null>)
(!= -1 <null>)
(!= <null> <null>)

Perhaps the answers are already in the new documentation, and you can guide me to them, or if not update it and guide me to them, as answering here might got lost.


RE: How are duplicate values handled in (remember Values <int>)? - Eric Piette - 11-30-2020

Hi,

Yes this is until they are forgotten for the remembered values.

No the (set Var ....) is also kept in memory along all the game, until that variable is modified once again.
Only the pending values are automatically reset after one move.

No the (set Var ...) can not be set in the starting rules.... That would be possible of course, but it would be much better to avoid that. These variables are there to allow more power into Ludii but are not nice to be used. We try to keep the .lud files as closer as possible to a game description which is not really the case if too many variables like that are used. Except if you know a game already existing which can required that.

If the value is tested before to be set the default value is returned (which is the most general default integer value in Ludii, UNDEFINED which is equal to -1 as described in the doc).

null is not allowed, see the grammar or the LLR. That's not a word of the language. Null can never be used, if a null pointer is reached a bug happens, that's why we check the most cases we can to return the default value in case of something impossible is tested, like if you try to get the value of a variable not set as explained just before.

All these information are in the doc in the sections related to that. Except for the "null" question, that's just not part of the language and we absolutely do not want that.

Regards,
Eric


RE: How are duplicate values handled in (remember Values <int>)? - dale walton - 11-30-2020

Many thanks for quick and helpful reply.

So guidance would be to avoid undefined values as much as possible, and to use variables as little as possible, except to implement games that demonstrate why an additional ludeme might be useful.


RE: How are duplicate values handled in (remember Values <int>)? - dale walton - 12-01-2020

In light of providing specific ludemes to avoid complicated coding, here is a suggestion that you may already have alternate methods to achieve, but might be easier.

I suggest a Boolean:
(was Changed ((state:[ Position | Score | Piececount | Emptycount | Any ] ) | (var:<"string - name of existing named var">)) [Player Role] [prev:(move | turn)]  [increase:(true | false)] )


RE: How are duplicate values handled in (remember Values <int>)? - Eric Piette - 12-01-2020

Hi,

In which purpose? What would be the utility of a such ludeme to describe a game? Do you have any example of a game which needs that?

Regards,
Eric


RE: How are duplicate values handled in (remember Values <int>)? - dale walton - 12-01-2020

Right. That was a framework suggestion for how various tests could be accommodated.
With your named state variable, this could all be implemented, but you seem to prefer a less programmed approach.
Changed state:Any is just your repeat state query but the others are a bit more specific.

I have a few games that have endings where after one player passes the movement rules become limited, or a placement is required or a score increase is required.

I could do something like (if (was Pass Prev) (priority ...

However when turns have optional moveAgain actions Ludii seems to take a Pass on the action to be a Pass on the turn and it can get complicated...
I'll come back to you on the specific ones that would be useful, so that you can tell me the more natural way to implement it.


RE: How are duplicate values handled in (remember Values <int>)? - dale walton - 12-02-2020

Ok, my currently pressing problem is that there is no differentiation between the first pass of a turn and a "pass" move used to end a turn that had previous move actions using moveAgain.

Possibly related?
I also notice in the Status list sometimes Player 0 to move, and was wondering if this might be related to undoing moves of the above type.

Sorry.  Please ignore the above --

I rechecked and the (all Pass) is working.  I will go back to hunt down where my own bug lies.


RE: How are duplicate values handled in (remember Values <int>)? - dale walton - 12-03-2020

I rechecked. (was Pass) and (all Passed) check the last move of each turn instead of the first move of each turn.

I believe that a turn with several moves ending in a pass is not a pass turn in the sense of an end-game condition that we normally want to check.
Also Ludii may automatically impose this test to end a game, so it should be based on a turn pass, not a move pass.

Can tests be provided for a turn-based pass (pass is the first/only move in a turn) rather than a move based pass?

If needed for backward compatibility, can an argument such as (was Pass Turn) (all Passed Turn)

If this is not possible, can an (endTurn move be provided that is not a pass. - This is not a preferred option. Making pass turn based is much more logical.