Ludii Forum
Mapping integers to strings - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Grammar Problems (https://ludii.games/forums/forumdisplay.php?fid=24)
+--- Thread: Mapping integers to strings (/showthread.php?tid=966)



Mapping integers to strings - Michael - 05-15-2022

It is apparently legal to define a map as a list of integer–string pairs, like this: (map "ToString" {(pair 1 "Cat") (pair 2 "Dog")}). So one would think (map "ToString" 1) evaluated to "Cat". But it doesn't..

As far as I can tell, there are no functions in the Ludii grammar that returns a string. Why is this?

(What I really want is a way to associate a value to a site in a way that does not follow the pieces. As far as I understand, the way (state) works now is that the state of a site can be changed if a piece moves from the site, even though (set State) has not been called, because the state is really associated with the piece, not the site. I started thinking about strings because I tried to do this with variables.)


RE: Mapping integers to strings - Eric Piette - 05-30-2022

Hi,

This is allowed for one single reason, the coordinates.
It is possible to do something like (pair "A1" "C3") which is going to convert the coordinates to integer.

But not for anything else, so not for your example with Cat.

Eric


RE: Mapping integers to strings - Mnaisoa - 11-16-2023

I understand that even though (set State) hasn't been called, a piece moving from the site has the ability to alter the state of the site due to the current way
spacebar clicker


RE: Mapping integers to strings - salpr112 - 02-06-2024

this is interesting