Planetary Annihilation "spiritual successor to T.A"

Talk about anything not related to FA or FAF here !

Re: Planetary Annihilation "spiritual successor to T.A"

Postby rootbeer23 » 08 Jun 2013, 21:47

Ze_PilOt wrote:PA download about 150 ko/sec. That's what the server need to upload/player.

So about 9 mb/second of replay, 270 mb for a 30 min skirmish game on a little planet..


all that is needed is a deterministic simulator for PA, then you can run 2 servers per game, one on
each node and exchange player inputs between them.
PA architecture is server based and its also P2P, once the determinism bugs have been fixed,
if you add a module to synchronize the state in the way FA does it.
or you can have 2 simulation servers, one in australia with 4 players connected to it and one
in europe, also with 4 players connected. in any case, the replays will be tiny again.
the PA engine is way superior to FA i would say. and if they make it deterministic and multithreaded
it will also require less expensive hardware.
think about it.
rootbeer23
Supreme Commander
 
Posts: 1001
Joined: 18 May 2012, 15:38
Has liked: 0 time
Been liked: 31 times
FAF User Name: root2342

Re: Planetary Annihilation "spiritual successor to T.A"

Postby Ze_PilOt » 09 Jun 2013, 12:20

They are not planning to make it deterministic because it's nearly impossible with multithreading.
Nossa wrote:I've never played GPG or even heard of FA until FAF started blowing up.
User avatar
Ze_PilOt
Supreme Commander
 
Posts: 8985
Joined: 24 Aug 2011, 18:41
Location: fafland
Has liked: 18 times
Been liked: 376 times
FAF User Name: Ze_PilOt

Re: Planetary Annihilation "spiritual successor to T.A"

Postby rootbeer23 » 09 Jun 2013, 18:54

its actually pretty straightforward: the simulation of planet A does not care a bit about the simulation of planet B and thus the relative order of processing of unit simulation between A and B has no effect on the simulation state at the end of a tick.
all you need to be careful about is a transport or other forms of communication from A to B. and that is clearly a minor amount of critical simulation that can not be parallel.

A common argument is that tank A tries to shoot tank B and on 2 different computers, first B was simulated then A and thus
A shoots at B's new position, while on the other one A shoots at B's former position. Its of course a valid point. But still tanks
dont shoot tanks on other planets.
rootbeer23
Supreme Commander
 
Posts: 1001
Joined: 18 May 2012, 15:38
Has liked: 0 time
Been liked: 31 times
FAF User Name: root2342

Re: Planetary Annihilation "spiritual successor to T.A"

Postby ColonelSheppard » 09 Jun 2013, 21:03

rootbeer23 wrote:A common argument is that tank A tries to shoot tank B and on 2 different computers, first B was simulated then A and thus
A shoots at B's new position, while on the other one A shoots at B's former position. Its of course a valid point. But still tanks
dont shoot tanks on other planets.

making planets completely independant in order to run sperate simulations? ehh... i dunno if that would be a good idea... it's like you base a whole game on some kind of workaround :shock:
User avatar
ColonelSheppard
Contributor
 
Posts: 2997
Joined: 20 Jul 2012, 12:54
Location: Germany
Has liked: 154 times
Been liked: 165 times
FAF User Name: Sheppy

Re: Planetary Annihilation "spiritual successor to T.A"

Postby uberge3k » 09 Jun 2013, 21:33

Ze_PilOt wrote:They are not planning to make it deterministic because it's nearly impossible with multithreading.

As I have pointed out many times before, It is trivial to maintain determinism in a multithreaded environment. I'm not sure why they keep saying that it isn't.

Step 1: Wrap each sizable block of processing in a tasklet data structure. A unit's main update function is the perfect place for this. Loop through each unit, creating the tasklets. Ensure that no live data is touched during the update function, and that all results are cached in thread safe, unit-local structures. It will be committed to each unit later in a separate commit function.
Step 2: Split these tasklets amongst N threads. Begin executing them, and processing collision detection on the main thread using the last current unit positions while waiting for it to finish.
Step 3: When all tasklets have finished, loop through the unit list again, applying the cached update results to the live values.

This is an extremely common pattern in multithreading, and quite simple to implement.
Ze_PilOt wrote:If you want something to happen, do it yourself.
User avatar
uberge3k
Supreme Commander
 
Posts: 1034
Joined: 04 Sep 2011, 13:46
Has liked: 2 times
Been liked: 48 times
FAF User Name: TAG_UBER

Re: Planetary Annihilation "spiritual successor to T.A"

Postby uberge3k » 09 Jun 2013, 21:36

Putting the simulation of each planet on a separate thread is indeed a suboptimal solution. It does not scale well, while the above solution will - eg, what if there is a 1k unit battle on a single planet? Or, what if there are 100 planets, each with 50 units? And so on.
Ze_PilOt wrote:If you want something to happen, do it yourself.
User avatar
uberge3k
Supreme Commander
 
Posts: 1034
Joined: 04 Sep 2011, 13:46
Has liked: 2 times
Been liked: 48 times
FAF User Name: TAG_UBER

Re: Planetary Annihilation "spiritual successor to T.A"

Postby rootbeer23 » 09 Jun 2013, 21:41

ColonelSheppard wrote:making planets completely independant in order to run sperate simulations? ehh... i dunno if that would be a good idea... it's like you base a whole game on some kind of workaround :shock:


first, the independence is not perfect, it applies only to the vast majority of units that have a range of influence which
is limited to one planet. all interactions between planets are simulated in sequence and thus deterministic with respect to all actions of the 2 communicating planets.
second, 2 units are not to be in communication and thus may be simulated in parallel if they cannot be effected by or effect each other for the duration of a single timeslot of the simulation, which is a fraction of a second. and the majority of units
cannot travel or shoot very far in such a short time.
all interaction between mutually independent realms is something that you cannot parallelize, but they still exist in the game of course.
rootbeer23
Supreme Commander
 
Posts: 1001
Joined: 18 May 2012, 15:38
Has liked: 0 time
Been liked: 31 times
FAF User Name: root2342

Re: Planetary Annihilation "spiritual successor to T.A"

Postby rootbeer23 » 09 Jun 2013, 21:47

uberge3k wrote:Step 3: When all tasklets have finished, loop through the unit list again, applying the cached update results to the live values.

This is an extremely common pattern in multithreading, and quite simple to implement.


it requires a lot of extra memory, extra cpu resources and above all, many more fetches from memory.
you are better off partitioning your units in such a way that state updates only interfere with units in the same thread.
a physics simulation is an inherently lock-free parallelizable thing, because the speed of light is not infinite and the spatial
seperation makes the paritioning straightforward.
rootbeer23
Supreme Commander
 
Posts: 1001
Joined: 18 May 2012, 15:38
Has liked: 0 time
Been liked: 31 times
FAF User Name: root2342

Re: Planetary Annihilation "spiritual successor to T.A"

Postby rootbeer23 » 09 Jun 2013, 21:50

uberge3k wrote:Putting the simulation of each planet on a separate thread is indeed a suboptimal solution. It does not scale well, while the above solution will - eg, what if there is a 1k unit battle on a single planet? Or, what if there are 100 planets, each with 50 units? And so on.


1k units on a single planet can be handled by a single thread.
100 planets with 50 units each can be handled by 100 threads. or 8 threads if you have only 8 cores, with each thread simulating multiple planets in sequence.
if you have 10k units on a single planet, you can divide the units among several threads, partitioning by planets is
only the most straightforward special case of partitioning by spatial coordinates.
rootbeer23
Supreme Commander
 
Posts: 1001
Joined: 18 May 2012, 15:38
Has liked: 0 time
Been liked: 31 times
FAF User Name: root2342

Re: Planetary Annihilation "spiritual successor to T.A"

Postby uberge3k » 09 Jun 2013, 22:23

rootbeer23 wrote:
uberge3k wrote:Step 3: When all tasklets have finished, loop through the unit list again, applying the cached update results to the live values.

This is an extremely common pattern in multithreading, and quite simple to implement.


it requires a lot of extra memory

Memory is a red herring. Let's examine why. A typical unit would need to store its position, velocity, and state data. Since this data would be cached, it would indeed add to the total memory requirements of the simulation. But how much?

Position and velocity would each typically be stored in a set of three 32-bit floating point values. For planets the size of PA, you could easily use 16-bit without any notable loss of precision, but we'll ignore that and use a worst-case scenario instead. There are probably a couple of turrets whose rotation need to be kept track of.So, that's (4*3*2) + (4*2) = 32 bytes of memory.

Now, how much more (mutable!) state data could a unit need? Keep in mind we're talking values such as current health, firing state, weapon timers, that sort of thing. Non-changing unit data need not be shared (eg, weapon cooldown times, max health) for obvious reasons. Let's assume that each unit can store 30 such values. Let's also assume that they're using 32-bit precision integers (eg, in case a unit needs 4 billion hitpoints). So, 4*30=120 bytes.

So we're at 152 bytes of data. Per unit.

For 10k units, that's 1.52MB more memory.

For 1 million units, that's 152MB of additional memory.

The next-gen consoles will have 8GB of memory. Not all of that will be available to each game as some is reserved for the OS and other tasks, but we can safely assume at least 4GB of that will be addressable by a game.

But we're talking about PCs. So let's check the latest Steam hardware survey: http://store.steampowered.com/hwsurvey

The overwhelming majority of systems have at least 4GB of RAM. The most common value is 8GB, and nearly 10% even have more than 12GB.

So, we can probably safely assume that the extra 152MB of RAM needed to properly cache unit thread updates won't break the RAM budget.

rootbeer23 wrote:extra cpu resources and above all, many more fetches from memory.

Which would certainly still be far less than the CPU time gained by threading the simulation instead of letting those cores sit idle. Memory fetches, while certainly something to consider, are likewise relatively trivial. Each unit would require, in the absolute worst case, 3x as many memory reads and writes. They are absolutely trivial on modern hardware.

rootbeer23 wrote:a physics simulation is an inherently lock-free parallelizable thing, because the speed of light is not infinite and the spatial
seperation makes the paritioning straightforward.

But what about the added memory requirements and the additional reads and writes required to use some form of grid registration, quadtrees, or similar forms of spatial partitioning to make that happen? :)

(We should also clarify that this is in reference only to physical simulations in the context of an RTS - true physics engines, such as Havoc, are relatively more difficult to thread properly)
Ze_PilOt wrote:If you want something to happen, do it yourself.
User avatar
uberge3k
Supreme Commander
 
Posts: 1034
Joined: 04 Sep 2011, 13:46
Has liked: 2 times
Been liked: 48 times
FAF User Name: TAG_UBER

PreviousNext

Return to Off-Topic

Who is online

Users browsing this forum: No registered users and 1 guest