Ludii Forum
Player to Integer - 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: Player to Integer (/showthread.php?tid=311)



Player to Integer - slimy_asparagus - 12-02-2020

What is the cleanest way to convert a player to an integer?
I would have the cleanest would be (id "P1") or (id "P2") but I cannot get it to work. I am trying (in a different game) to do something like:

Code:
        (piece Foreground "Square" state:(id "P1") image:"disc" fillColour:(colour Black) scale:0.4)
        (piece Foreground "Square" state:(id "P2") image:"cross" fillColour:(colour Black) scale:0.4)

In a related question, are we forced to identify a player with a colour? A few games resist that and use symbology instead.


RE: Player to Integer - Eric Piette - 12-04-2020

Hi,

Just with (id P1).
P1 to P16, Neutral, Shared, All, Mover, Next, Prev, etc... are RoleType and can all be converted to their index value with (id ...).

Regards,
Eric


RE: Player to Integer - slimy_asparagus - 12-04-2020

(12-04-2020, 08:09 AM)Eric Piette Wrote: Hi,

Just with (id P1).
P1 to P16, Neutral, Shared, All, Mover, Next, Prev, etc... are RoleType and can all be converted to their index value with (id ...).

Regards,
Eric
Eric,

Thanks for looking. I cannot remember whether I tried that particular formulation. I can  now see that it is what the documentation would imply. However when I try I get a non-specific compile error. I attach the file I was working on (which is pretty simple).


RE: Player to Integer - Eric Piette - 12-04-2020

Hi,

Oh, be careful, you are using some IntFunction ludemes in the metadata. The metadata are not part of the logic. Only simple integers can be used in them. You should be able to check that in the LLR. So the ludeme (id ...) which is an IntFunction can not be used in the metadata.

Except the LLR, no guide exists about the metadata, we are discussed about writing one in the future, but that's not sure and not a priority for the moment.

Regards,
Eric


RE: Player to Integer - slimy_asparagus - 12-04-2020

(12-04-2020, 04:09 PM)Eric Piette Wrote: Hi,

Oh, be careful, you are using some IntFunction ludemes in the metadata. The metadata are not part of the logic. Only simple integers can be used in them. You should be able to check that in the LLR. So the ludeme (id ...) which is an IntFunction can not be used in the metadata.

Except the LLR, no guide exists about the metadata, we are discussed about writing one in the future, but that's not sure and not a priority for the moment.

Regards,
Eric
Okay. Thanks. I think that means I have to take a different approach for that one. That's okay because I did consider an alternative.

However just out of curiosity I did wonder if that would be the answer and I tried an experiment. The attached test.lud still fails to compile.  Fixing it is of no concern to me, but from what you are saying it seems it ought to compile so I am puzzled.


RE: Player to Integer - Eric Piette - 12-04-2020

Hi,

Same thing for the starting rules, they are not using the IntFunctions. These functions, in general, needs a state to be run, however, the starting rules are building the initial state. So in general the functions are not possible in them.
You can look that in the LLR, but as a general rule no function inside the graphFunctions (building the board, so the initial state), the starting rules or the metadata.

Regards,
Eric


RE: Player to Integer - slimy_asparagus - 12-04-2020

(12-04-2020, 04:46 PM)Eric Piette Wrote: Hi,

Same thing for the starting rules, they are not using the IntFunctions. These functions, in general, needs a state to be run, however, the starting rules are building the initial state. So in general the functions are not possible in them.
You can look that in the LLR, but as a general rule no function inside the graphFunctions (building the board, so the initial state), the starting rules or the metadata.

Regards,
Eric
Thanks. That does explain why Reversi was coded the way it was.