How would I make a turn based system with simultaneous turns? (C#)

I’ve found a few good tutorials for driving a round-robin turn system with events and states in C#, but I’m having trouble applying that to what I want to do.

What I want for my game is a system with a “Planning Phase” where each player (and each AI controlled character) all describe simultaneously what they want to do, and then an “Execution Phase” where the planned actions occur, and the game engine resolves conflicts.

The best way I can think of is for there to be some data structure that each player’s planned actions are submitted to, and every time someone submits it checks if they were the last one and ends the planning phase if that’s the case. The execution phase is pretty trivial by comparison because it doesn’t involve player action.

However, I have absolutely no idea how to even start to rig that up, and I’m probably wrong about it too. Any help at all would be very appreciated.

This is actually complicated stuff, so take your time researching and designing. (Also, FYI, since this isn’t specifically Unity-related, the mods may close this question.)

The execution phase isn’t necessarily so trivial, because it has to handle conflicts. Let’s say player A moves out of location (0,0) in the same turn that player B attacks A in (0,0). Does player A evade the attack, since he moved away? Or does player B stop A by attacking? Two typical solutions are:

  1. Run a time-based simulation. If player A can move in 1 second, but it takes player B 2 seconds to start an attack, then player A evades.
  2. Resolve conflicts with some kind of hierarchical rule-based system that sets rules such as “attacks always take precedence over movement”.

Getting your conflict resolution down right is critical to the playability of your game, since they’re going to happen all the time. After all, tactics are only interesting when they involve more than one party.

The planning phase is easy for human players, since they do all the work; you just need to provide a pretty interface for them to input their commands.

AI planning is the subject of limitless pages of AI research. I suggest starting at http://aigamedev.com/ - they have lots of really good articles available for free.