also about states

Game development with Board Game Arena Studio
Post Reply
User avatar
ddyer
Posts: 67
Joined: 01 April 2011, 19:55

also about states

Post 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.
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: also about states

Post 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,
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: also about states

Post 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
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: also about states

Post 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 :)
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: also about states

Post by Rudolf »

'I like' the answer :)
you see now how we could (badly ) use it!
User avatar
ddyer
Posts: 67
Joined: 01 April 2011, 19:55

Re: also about states

Post 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.
User avatar
ddyer
Posts: 67
Joined: 01 April 2011, 19:55

Re: also about states

Post 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.
Post Reply

Return to “Developers”