ConcurrencyI created an RTS simulation in which two factions fought over control of territory.  All processing was done asynchronously in parallel prior to the render pass.  Utilized a dual-core Intel processor and found maximum performance between 3 and 5 total worker threads.  Also implemented a lockless FIFO using a linked-list structure in order to maintain the process list.

Download Code – Lockless FIFO

The first video shows the RTS simulation running.  The colored lines represent shots between soldiers (blue fires green).  Regular soldiers can fire at enemies within 10 units of themselves.  If they cannot find a soldier within that range, they move semi-randomly with a preference for the nearest enemy.  Several snipers are also on each team and fire at the furthest enemy.

Simple RTS

Simple Run of Simulation

The second video shows the simulation handling a much larger pool of soldiers.  The AI was very primitive but as I didn’t create a quad-tree or other spatial partition for the project, each soldier had to check every other soldier in the simulation for whether it was a valid firing target.  Since the intent was to explore the benefits gained from concurrency, I intentionally left out any optimization in the soldier processing.  Overall, for an O(n2) operation, the simulation was highly performant.

Complex Run

More Complicated Run