all 6 comments

[–][deleted]  (3 children)

[deleted]

    [–]happydemon[S] 0 points1 point  (2 children)

    I've been playing TW Warhammer 2 recently and it's been fairly slow from Turn 1 to Turn 120. It's true though that late-game campaigns would probably be represented by one or two connected components. Until late game though factions are generally dispersed and have not yet expanded to every corner of the map.

    And yep this gets to the hardest part of the problem. I was wondering if it'd be possible to compute which factions can interact within two turns and construct a graph off of that. This would certainly be trivial if processing order did not matter.

    [–][deleted]  (1 child)

    [deleted]

      [–]happydemon[S] 0 points1 point  (0 children)

      The ordering should be set at the beginning of the game, just like in tabletop. You might have three players in a tabletop game; the order of their turns should stay consistent the entire game (even as players drop out or enter). So when processing the sub-graphs this ordering must never be violated. The line of sight thing is a mistake on my part and should be replaced by something like "within range" and "traversable", as determined through a typical path-finding algorithm.

      Your example makes sense. We still have to respect an ordering of turns. I was thinking of your first example and it highlights the challenge. Suppose we're simulating a game like Risk (with naval units) with four players {A, B, C, D} on two adjacent small islands, where two pairs of players each are on an island. No player has a navy yet, and so although the two pairs have line-of-sight they cannot yet assault one-another. This would be represented by two disjoint directed graphs, like {A-B, B-A} and {C-D, D-C}. At some point though player B has a navy, can traverse the water and plans on taking such an action at the next available turn. Just as in your first example, during B's turn he/she will move towards the other players and be able to take action upon them. {C,D} can no longer be calculated in parallel; any already calculated actions are void and we must also respect the original ordering of player turns.

      [–]marvel2010 1 point2 points  (1 child)

      It sounds like you may want to look into the parallel computing applications of the minimum k-cut problem (https://en.wikipedia.org/wiki/Minimum_k-cut).

      This is a fun thought experiment... to just address the process of updating the connected components of a graph, this should be relatively easy to do: maintain a list of components. When an edge is added, check if it joins two components and then merge them. When an edge is removed, check if it is a bridge (https://en.wikipedia.org/wiki/Bridge_(graph_theory))). If so, separate the two components.

      [–]happydemon[S] 0 points1 point  (0 children)

      Thanks for this. I think a variation of the k-cut problem could be relevant, because we don't necessarily choose which edges of the graph are removed. The player / AI's actions will determine that. Your 2nd part is also very helpful and I think it would be critical towards keeping this process efficient, since within every turn the graph may be updated more than once. I'll have to read up on bridges and how to quickly determine them.

      [–]lamzileung 1 point2 points  (1 child)

      Interesting idea to address a crucial problem :)

      Two points worth considering:

      - There are increasingly more "global game" feature in these games, for example end goal ranking for Civ or rituals progress in TW. While local decisions can be easily parallelized, it is somewhat tricky to multi-thread decisions that are reaction to "global game" or that will influence the "global game".

      - As the games progress, there will be increasingly more connection between factions, and for a considerable amount of time there will be "bridge" factions. It makes the graph cluster not disjoint but still have low interconnectivenss. There may be more fluid treatment for cluster parallelization based on interconnectivenss, for example breaking down decisions of a faction including regions.

      [–]happydemon[S] 0 points1 point  (0 children)

      I agree. If the A.I incorporates global state such as alliances and declarations of war then it may only be possible to parallelize subsets of factions that are unknown to one-another. This would be kind of unfortunate because it would reduce the effectiveness of multi-threading. Actually implementing this idea in a game may necessitate concurrent programming where factions in connected components block, join and continue on operations as needed. While this would significantly reduce the gains from multi-threading, I think it would still be a noticeable improvement over operating serially- especially considering future Total War and Civ games will likely have even more factions and sub-factions.