Dev Diary #15: Country Control and Observer Roles

In short: In MKA Engine strategy-game projects, country control records the link between a player and a country. The engine checks this link for a command only when its type declares a country-control rule; observer access follows a separate player-role rule. At the start of a new game, the starting countries are assigned to the AI-role player, and ironman mode closes country switching except for a specific loss-of-country case.
What was the problem?
In a strategy game, choosing a country is more than highlighting a marker on the map. A game can define which command types check the sender against that country. For those commands, the engine checks the request before the game's ordinary rule; relying only on the selection screen leaves commands arriving by other routes outside that check.
There are two separate questions: “Who is the player?” and “Which country do they control?” Treating them as one record would make it harder to distinguish an observer from a human with no country and to handle country switching consistently.
How did we solve it?
We keep the player’s role and country control as separate pieces of information. The role says whether someone participates as a human, the AI or an observer. The control record links a player to a country; the engine uses that link in a command only when its type declares the country-control check. This relationship describes in-game control, not ownership of the land.
When a new game is set up, the engine assigns the starting countries to the player in the AI role. Game rules can use this control information, but the game’s own rules determine which strategy to choose. A game may ask whether a country is under AI control; the engine answers from whether a human controls it. That label says who has control, not how the game’s AI chooses its moves.
When a human chooses a country, the engine checks that the country exists and is not controlled by another human. A country controlled by the AI-role player can be transferred to the human. Once the change is applied, the player’s previous country controls are released, the new country is assigned to them, and their role becomes human.

When a command type declares a country-control check, the engine verifies—before the game’s ordinary rule—whether the sender controls the country named in the command. This country check is not applied automatically to every command type; observer access is a separate player-role rule.
How is an observer different?
An observer is a separate player role with no country control. Choosing to observe releases the player’s previous country links. From then on, they may use only commands that are open to observers. Country selection is one of those commands, so an observer can return to governing a country when the game mode allows it.

This distinction matters: country control is checked for a command only when its type declares that check; player-role rules separately determine which commands observers may use.
Choosing under ironman mode
Ironman is a game mode that closes some choices after it is enabled. While it is active, ordinary country switching and becoming an observer are refused. During setup, the country or observer choice is made before ironman is turned on.
There is one exception when a player loses all of their countries: if every country they previously controlled has disappeared from the game world, they may choose a new one. An observer who never controlled a country cannot use this exception; there is no lost country to replace.
What did we see?
| Situation | What the engine does | What the player can do |
|---|---|---|
| A new game begins | Assigns the starting countries to the AI role. | Game rules make their own decisions; the engine keeps the control relationship. |
| A human chooses a country | Transfers an eligible country to the human and releases previous controls. | The player may act for it in commands that declare the country-control check. |
| A command declares a country-control check | Before the ordinary game rule, checks whether the sender controls the country named in the command. | The command proceeds to the game rule only after passing this check. |
| A player becomes an observer | Releases country links and gives the observer role. | The player can use only commands open to observers. |
| Ironman mode is active | Refuses ordinary country and role changes, with an exception for a player who loses every country. | A new country is available only if all previously controlled countries are gone. |
The game state is the stored information that makes up the world; player roles and country control are part of it. Saving and resuming therefore preserves who controls each country.
Why did we choose this approach?
The country-selection screen can vary; a game defines which command types use country control. For those commands, the engine checks the sender-to-country relationship before the ordinary game rule runs. Observer access is governed separately by player role. The country check prevents a player from acting for another country only in commands that declare it; the game design, not this mechanism, chooses the AI’s moves.
What does it cost?
Country control is stored with the game state. The engine’s country-control check runs only for command types that declare it; observer-role rules are evaluated separately. We did not measure time or memory for this change, so we make no speed-improvement claim.
What comes next?
In the next diary, we explain the map tool’s job and why map choices belong to the game: A game-independent map tool.
Frequently asked questions
Does the AI control every starting country?
When a new game is set up, the starting countries are assigned to the player in the AI role. The game’s rules determine which strategy it follows.
Does country control apply to every command?
The engine’s country-control check runs when the relevant command type declares it. Which commands are open to observers is governed separately by the player-role rule.
Can an observer choose a country?
Yes, country selection is open to observers too. The request is normally refused while ironman mode is active.
When can a new country be chosen in ironman mode?
Every country the player previously controlled must have disappeared from the game world. An observer who never controlled a country is not covered by this exception.
For an overview, see MKA Engine and the earlier diary on how multiplayer orders stay consistent. Browse the MKA Engine diary series, or use the contact page with questions.