Page 1 of 1
also about states
Posted: 28 March 2013, 17:59
by ddyer
It seems like an accident that states have both names and numbers. The state
engine transitions are in terms of numbers, which are not used anywhere else,
but which have to remain consistent.
Re: also about states
Posted: 28 March 2013, 18:37
by sourisdudesert
Hello,
Numbers has to be unique, by construction.
Names should be unique... but you can use the same name for 2 game states if you want to. Then, you can test the name of the game state and apply the same logic to all game states with a specified name. However I don't recommend this approach
Cheers,
Re: also about states
Posted: 28 March 2013, 18:43
by Rudolf
I understood the question in another way:
maybe ddyer would like to suppress numbers because they are not used? is it right?
if so, I would answer that I use these numbers with Select / Case (case 1: case 43:)
And I suppose it was done for that?
Rudolf
Re: also about states
Posted: 28 March 2013, 18:47
by sourisdudesert
Hello Rudolf,
In theory, you're not supposed to use states number in your code, only game state name. This makes things easy if you need to change your state numbers for -whatever reasons-.
Well, basically ddyer is right: it may be possible to get rid of numbers. But it has been done like this, and would be a mess to change now

Re: also about states
Posted: 28 March 2013, 18:51
by Rudolf
'I like' the answer

you see now how we could (badly ) use it!
Re: also about states
Posted: 28 March 2013, 19:21
by ddyer
sourisdudesert wrote:Hello,
Numbers has to be unique, by construction.
Cheers,
Actually, I discovered accidentally that there's no enforcement of uniqueness. If two
states have the same number, the first one is ignored. It should be possible (using
either names or numbers) to check that the state engine is self-consistent, but it's
not done.
Re: also about states
Posted: 28 March 2013, 19:36
by ddyer
Another problem (source for programming errors) is that the state names are
defined in the .stat file but used in the php and js files, where the state names
have to appear separately but consistently.
Another bit of polish would be if the names of the states were made available in the
js and php environments, so that as a matter of style you would have a constant
"playStone" as the name of a state in only one place.
-- One of the problems with publishing an interface and inviting outside developers
is that artifacts like this tend to be frozen in place, warts and all.