1
\$\begingroup\$

So this question is code or engine agnostic but, I’m looking for ideas on how a game can keep track of a pre-determined number of factions or alliances. For example, say I made a space game that has 2 major and 3 minor federations of planets. A planet may join or leave a federation, but the federation itself may have an alliance or be at war with another (actually, to keep it simpler, I think all these changes will solely be reliant on the player’s actions).

However, I would also like to keep track of such diplomatic endeavours on the ‘individual’ level as well. Say the player has joined one federation that is at war with another. If the player should encounter another ship of the opposing federation, that ship becomes hostile. On the other side, two ships have an alliance, they might help one another.

What is the best way to keep track of all this?

One way I was thinking was creating a manager that holds all the Federation classes (which hold the status it holds with all other federations — say less than 0 and the federations are at war; more than x-amount, there’s an alliance). Meanwhile, each player/ship holds similar data in its class, along with its current alliance to whatever federation. Is my thinking logical in this or are there better ways of managing such things? Many thanks.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I don't know what the best way is, but if you are just interested in the current relationship between entities you could go with a manager. Decide how entities are connected, then save the individual relationships and check them hierarchically.

Federation A is at war with Federation B Ship A belonging to Federation A is allied with Ship B belonging to Federation B -> When Ship A meets Ship B they are allies, but any other ship from Federation B would be considered an enemy.

If you also need to keep track of which things happened in the past you could look into implementing a block chain. That way you have the current state of things and can trace every change back to the beginning of the game.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ A block chain? In an offline single player game? Why not just keep a journal in a regular list data structure? \$\endgroup\$
    – Philipp
    Commented Feb 28, 2021 at 11:27
  • \$\begingroup\$ Just an idea. While implied, it wasn't actually specified that this is strictly for an offline single player game. Not that that makes much of a difference, since the different entities in the game would be the "people" acting on the block chain. Either way I mainly think block chains are interesting because of smart contracts, which might allow for fun game mechanics. In the end I don't think there is one right answer and it mostly depends on what exactly the data is going to be used for. If all you want to do is display the history some kind of list will serve that purpose perfectly fine. \$\endgroup\$
    – Nisca
    Commented Feb 28, 2021 at 17:28
  • \$\begingroup\$ Thanks. I think I will look into block chains. \$\endgroup\$
    – ACour008
    Commented Mar 24, 2021 at 0:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .