Do not use Lockstep strategies in RTS

Hello, Habr! I represent to your attention translation of the article Don't use Lockstep in RTS games.


Lockstep lost! The client-server model won and became the standard for most games. Strategies in real time was the last, but Lockstep is used less and less. Let's find out why, but first, what is Lockstep?



the games have a few players playing the game on the client. But how to make sure that they play the same game? Using Lockstep all clients run the same code with the same parameters and input data. For example, if a player orders the army to go to the specified point, this command is broadcast to all the clients and all the army moves to the specified point. Even generator random pseudo-random numbers should be the same at all, this is usually done by using the same seed at the beginning of the game and execute in the same order. It is very effective from the point of view of the network, because only transferred teams. Such things as the order or action take up very little space in a network packet.


Lockstep — a very effective model of network interaction, but difficult to implement due to problems of desync or differences in compilers/platforms. Lockstep has been used in the past because the network bandwidth was very low. It worked just fine. Conceptually, it's very easy to add to an existing game. For example, DOOM, which has already been written and everything worked. To add multiplayer, John Carmack had to run the command on each computer. It is very easy in theory, before delays or differences in architectures will ruin everything. In practice, this is difficult to do. The programmer must make sure that all commands are executed in the same order on each client. What if someone did not receive a command in time? The client must wait for confirmation of receiving the command from all clients. What happens if someone reconnect? The first thing that comes to mind is to fake the whole game from the beginning, which can take a lot of time.



using Lockstep'and the programmer must make sure that the compiler does not optimizes operations with floating point numbers, because different processor architectures may have small differences in the result of the same calculation. This is especially true if you are trying to sync your PC and iPad. The differences of the architectures is a nightmare for Lockstep. If you are working with HTML5 Javascript JIT can optimize the computation for different, doing a small errors, which can lead to big changes. Programming Lockstep — how to hold a lot of weight on the tip of a knife.


If that is not enough, use a p2p Lockstep, inheriting all the problems of the second. If you are using TCP, you can connect any two computers over the Internet due to firewalls, NAT s, proxy, VPN... etc. With UDP have a chance to do hole punching. Fortunately, browsers support webRTC, which runs over UDP and has an API for hole punching using STUN server. At least, this part can be done using HTML5.


what is A Client-server model? It's just when a client joins the server and the server sends the client updates. Ready! The server and client can use different code in different languages and even platforms. The server has full control over the game. There's no knife, the tip of which need something to hold. The main problem is that the server needs to send more updates. This is because the movement of each unit, the shot bullet, the change in health needs to be synchronized. Fortunately, the network of users expands and is cheaper than programmer time.


the Reason why RTS used the Lockstep was the width of the channel. In FPS, the movement 32 of people do not require a large amount of traffic. In RTS of 1000 requires more traffic, but the width of the channel allows it.



Lack of servers — they cost money, while Lockstep is not needed for the server, all p2p. Well, there are providers from whom you can rent servers. But if it's still too expensive, you can run one server on one client ... it's like Lockstep ... except that there is one authorized client, and that it has more to load.


Examples:


    the
  1. StarCraft 1 used Lockstep, while StarCraft 2 uses a Client-Server model.
  2. the
  3. Supreme Commander 1 uses Lockstep when newer games like Planetary Annihilation that uses Client-Server model.
  4. the
  5. DotA runs on the Warcraft 3 engine which was used in Lockstep, but Valve uses the Client-Server model for Dota 2.
  6. the
  7. DOOM used the Lockstep but Quake uses a Client-Server model with Lockstep at all is not popular in FPS.
  8. the
  9. MMO never used Lockstep because it is not applicable for such a large number of players.

the Development of programming depreciation of computers and modern Internet speed do Client / Server is easier to apply than Lockstep. Lockstep will be used less and less.

Article based on information from habrahabr.ru

Comments

Popular posts from this blog

Powershell and Cyrillic in the console (updated)

Active/Passive PostgreSQL Cluster, using Pacemaker, Corosync

Automatic deployment ElasticBeanstalk using Bitbucket Pipelines