Page 1 of 1

"State machine file is too big" - what am I doing wrong?

Posted: 15 October 2020, 07:14
by salty-horse
When I run Victoria_La's project checker, it warns that my state machine file is too big (231 lines at the moment).
I'm not sure if I should ignore it, or if I'm misunderstanding how to use the state machine.

My game, Mottainai (rules PDF), has 8 phases in a player's turn, and one of these phases is a loop that goes through all opponents, and a subloop where you perform an action several times. And another two phases have loops where you can optionally activate card effects in any order.

And this is just the core flow, that I'm still not done implementing and will probably need 2-3 more states. There are 50+ card effects to implement, many of them unique (not variations of each other), and each one requires different prompts from the players.

Is this something that can be implement with a small number of states?

Here's my code for reference: https://github.com/salty-horse/mottainai-bga
Note that the states file has few leftovers from the Hearts tutorial, but these should be a good stand-in for the states I'm still missing for the core game flow.

Re: "State machine file is too big" - what am I doing wrong?

Posted: 15 October 2020, 09:08
by Tisaac
The file look ok to me. I'm usually putting the define in a separated constants.inc.php file which contains other defined constants.
There is always a tradeoff between number of state and complexity of state, the two extreme being :
- only one state which handle all the game, very complex to debug
- a very large number of simple states
You have to find a good compromise but there is no general rule for that.

Re: "State machine file is too big" - what am I doing wrong?

Posted: 15 October 2020, 09:10
by Lymon Flowers
I don't think you need a state every time you have a new prompt. Stuff like this can help:
https://boardgamearena.com/forum/viewto ... 741#p65677

That would help lowering the state numbers.

Re: "State machine file is too big" - what am I doing wrong?

Posted: 15 October 2020, 17:44
by salty-horse
bdrieu wrote: 15 October 2020, 09:10 I don't think you need a state every time you have a new prompt. Stuff like this can help:
https://boardgamearena.com/forum/viewto ... 741#p65677

That would help lowering the state numbers.
I'm not sure if this is applicable to my situation. I use state to mark different places in the game flow. If I ever have identical prompts, they will be in different places in the game.

For now, I know to ignore that warning about the line count in the states file. Thanks!

Re: "State machine file is too big" - what am I doing wrong?

Posted: 15 October 2020, 20:20
by Lunalol
Don't worry, I have 633 lines in my state file.

Re: "State machine file is too big" - what am I doing wrong?

Posted: 16 October 2020, 01:37
by Victoria_La
You can ignore it, but the more states you have the more complex the game and more unmanagable. 200 lines is actually not bad, I think I should change it to count numer of states not the lines though :)