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



String concatenation - Alain Busser - 08-06-2023

Hello,

if there is a
Code:
(piece "Ball" Each)

in the start rules, player P1 has pieces called "Ball1" and player P2 has pieces called "Ball2". This means that at compilation the string "Ball" is concatenated with "1" or "2". Is there a way to do the same thing with the word "Track" so that player P1 has "Track1" and player P2 has "Track2"?

Or is there a way to associate each player with his track, so that I could write something like

Code:
(trackSite Move "Track" owner:(mover) steps:(size Stack at:(from)))


In the included file, I had to do something a bit tricky to make it work (P1 sows from left to right, P2 sows from right to left, and if the last seed sowned falls into an empty place the player looses; by the way it is the simplest sowing game I know - great for children).

I tried with a map but a ludeme beginning with "mapEntry" after Move is not accepted at compilation.


RE: String concatenation - fuerchter - 08-08-2023

Hi,
here's what an updated .lud of this could look like, and the changes I made. This is based on (trackSite Move) taking the roleType OR the player OR the name of the track, so it doesn't use string concat as you suggested, but it is simpler. And using just a single "(sow "Track" owner:(mover))" works because if you give it an owner it will just check if a track "contains" the name.