3

In Rise of Nations, what happens when two of the same wonders are completed at the same time? This happened to me in a game and before I completed my wonder I won. What would have happened though?

1 Answer 1

6

I am speaking as a programmer here, though I was never involved with the development of RoN.


What happens, when a player has finished building a wonder while another player is still building it, is that the wonder that's not yet finished building will be destroyed.

Statistically speaking, it is impossible for 2 players to finish an action at the same time, simply because a computer is capable of processing millions of instructions per seconds (computers nowadays can even manage billions), so even if it looks like you both performed an action at the same time, you are usually apart by a timespan ranging from a few nanoseconds to several milliseconds.

However, let's assume that within the same game loop, you managed to finish building a wonder at the same time as another player, what happens then?
Well, the truth is; you still didn't finish building the wonder at the same time, but why?
Computers are really amazing machines; they can perform so many tasks concurrently. Actually, they can't.
Like I mentioned before, computers are really fast. When a game like RoN needs to process a single game loop, what happens is that it loops through all available players, updates the status of their armies and cities, see what keys the players are pressing on their keyboards, or process the AI's next move. All of which happens at such a high speed, that we are left with the illusion, that all these tasks were completed at the same time.
The moment a wonder has finished building, the game logic will keep that fact in memory and upon updating the status of the other player's wonder, will trigger a cancellation.
If this case ever happened, which wonder would complete, and which would be cancelled? Well, Player 1 would always win in such a situation since loops are usually processed from 0 to n-1 (n == number of players). Obviously, Player 2 will win against any other player other than Player 1, and so on.

Okay, but let's assume the game was making use of multiple cores and could process multiple players concurrently.
Now we are moving into the obscure world of parallel computing. In this case, anything could happen; the game could crash (race conditions), or you could end up with two players with the same wonder (also race conditions), or the game may behave normally (thread 1 was faster than thread 2; you were lucky), or you might even have a situation where the same wonder is featured on two different locations on the map but no player actually benefits from the wonder's effects (consistency problem). The exact behaviour greatly depends on how well the game was programmed, and even when knowing the source code, the effects may be completely unpredictable. Because of this unpredictability, bugs pertaining to multithreading are notorious for being extremely difficult to detect, much less fix.

Since parallel computing is a fairly complex and wast theme, I'm not going to explain it in more detail.


TL;DR

Nothing special will happen. Whoever the computer thinks has finished the wonder first, will have the wonder, while the other player will end up with nothing but rage for having wasted his time in vain.

3
  • Best answer ever........ Commented Jul 25, 2013 at 19:07
  • The most likely scenario is definitely not a crash.
    – Decency
    Commented Jul 25, 2013 at 19:12
  • @Decency Like I said, it's highly unpredictable. I was assuming they were using a non-concurrent look-up table to see if a wonder is finished, since that's faster than looping through all wonders. In C#, trying to add a key-value pair to a dictionary when another pair with the same key already exists would crash the app. I don't know how it would behave in C or C++ though... If they are using a concurrent look-up table, then it would probably behave correctly.
    – Nolonar
    Commented Jul 25, 2013 at 19:15

You must log in to answer this question.

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