07-30-2020, 01:44 PM
(This post was last modified: 07-30-2020, 03:18 PM by DennisSoemers.
Edit Reason: Easier to read the code like this
)
I am programming a game where new groups are seeded by players every turn, and automatically "grow" at the beginning of each players turn. The code looks like this - which, by the way, is very close to the actual intended game.
In the code, players first add a new stone to the board, and then all groups grow. However, the game is intended to be the opposite - first, all of a player's groups automatically grow, and then they place a stone. I have programmed this way because I read that NonDecisions can only come as the effect of a move, or following a player decision. Is there a way to have an effect trigger automatically every turn, followed by a player move? All my attempts to script it failed. Cameron suggested I first check if it is the first turn with (if (= (count Moves) 0)) (move Add (to (sites Empty))) or something similar, so that the game doesn't try to "grow" non-existent groups (I temporarily made a random 3-stone pie to overcome this). But I could not figure out how to place such a check into context, like at what point to perform this check. I looked at the Amazons code and tried to do something similar but it never worked for me.
Alternatively, I could stick with this Decision --> Effect architecture, but make the effect grow all of the Mover's groups EXCEPT the stone just placed. How could I make exceptions in sites Occupied by Mover to exclude the last stone placed?
The other way would be to have the growth affect the Next player's groups. However, this results in adding the Mover's stones to the Next player's groups, which is not the desired effect. How could I modify the command above to add the Next player's stones to the Next player's groups?
Finally, I made a random pie, but it would be nice to have a phase where one player adds all 3 stones intentionally for the other person to choose sides. Is there examples of more complex pie offers already coded in Ludii that I could take a look?
Thanks for any help. Even if I see a solution for one of these problems, I am interested in all answers to all questions, because it will help me design more Ludii games in the future.
Code:
(game "Inkblot Variant"
(players 2)
(equipment
{
(board (tri Hexagon 19))
(piece "Ball" Each)
}
)
(rules
(meta (swap))
(start (place Random {"Ball2" "Ball1" "Ball2"}))
(play
(move Add (to (sites Empty))
(then (add (to (expand (sites Occupied by:Mover) steps:1 Orthogonal))))
)
)
(end (if (no Moves Next)(byScore {(score P1 (count Pieces P1)) (score P2 (count Pieces P2))})))
)
)
In the code, players first add a new stone to the board, and then all groups grow. However, the game is intended to be the opposite - first, all of a player's groups automatically grow, and then they place a stone. I have programmed this way because I read that NonDecisions can only come as the effect of a move, or following a player decision. Is there a way to have an effect trigger automatically every turn, followed by a player move? All my attempts to script it failed. Cameron suggested I first check if it is the first turn with (if (= (count Moves) 0)) (move Add (to (sites Empty))) or something similar, so that the game doesn't try to "grow" non-existent groups (I temporarily made a random 3-stone pie to overcome this). But I could not figure out how to place such a check into context, like at what point to perform this check. I looked at the Amazons code and tried to do something similar but it never worked for me.
Alternatively, I could stick with this Decision --> Effect architecture, but make the effect grow all of the Mover's groups EXCEPT the stone just placed. How could I make exceptions in sites Occupied by Mover to exclude the last stone placed?
The other way would be to have the growth affect the Next player's groups. However, this results in adding the Mover's stones to the Next player's groups, which is not the desired effect. How could I modify the command above to add the Next player's stones to the Next player's groups?
Finally, I made a random pie, but it would be nice to have a phase where one player adds all 3 stones intentionally for the other person to choose sides. Is there examples of more complex pie offers already coded in Ludii that I could take a look?
Thanks for any help. Even if I see a solution for one of these problems, I am interested in all answers to all questions, because it will help me design more Ludii games in the future.