Please add deterministic lockstep networking for RTS style games

I would like to hear from Epic guys what they think about possibly adding deterministic lockstep networking for RTS style games.

As far as I know you want your engine to be used with any type of game, and for RTS and similar genres (with thousands of units) deterministic networking is the only solution. So all people who want to make such a game will have to code that themselves, and I guess for most indie devs adding such complex low level stuff is not really easy, aside from the fact that people like me who only use blueprints have absolutely no chance to implement this.

So at the moment UE4 is not suited to create a multiplayer RTS game if you are not some AAA . I would really like this to change.

Do you guys at epic have any plan to integrate this feature into the engine? :confused:

What exactly is keeping you from replicating your data as needed? Is it too slow for the number of units? Are you missing functionality(and if so, what)?

The replication model isn’t a great base for implementing lockstep networking and would want replacing entirely, IMHO, but I do believe the replication model is adequate so long as you are clever about how you handle things and realistic about your expectations and goals. You can certainly make a multiplayer RTS in UE4, and UI reckon you could have a Company of Heroes scale game working pretty happily using just Blueprint.

[=;208262]
So all people who want to make such a game will have to code that themselves, and I guess for most indie devs adding such complex low level stuff is not really easy, aside from the fact that people like me who only use blueprints have absolutely no chance to implement this.
[/]

I’d like to inject a little bit of realism into this one here - if adding such a complex feature that is very specific to your game isn’t viable for you as a developer, you should pursue another route.

[=;208262]
Do you guys at epic have any plan to integrate this feature into the engine?
[/]

There are no plans to my knowledge.

Hi ,

Thank you for your feedback, we will take this into consideration.

Whilst we’re here, I’d like to throw in my support for an alternative lockstep network model - I know I could put it to use :wink:

1 Like

Hey , any news? :cool:

Lockstep protocol is to prevent Look-ahead cheating (with this cheat you can trick other clients into thinking you have high latency while for you there isn’t).
This means you can do actions in the game while the others have to wait.

For this reason we don’t really see multiplayer RTS games popping up (only single player examples). Like John says not unless you have "AAA " resources.

Perhaps with a little push from the Epic team would help?:rolleyes: puppyeyes
Would love to have an ‘Example RTS project’ (multiplayer ready) to learn from.

It’s not only to prevent cheating, prevented cheating is just a nice side effect :cool:

1 Like

This is a question that has been raised in every generation of the Unreal Engine, and it is definitely not in the works. Lock-step execution can only work if every engine system on every platform is designed for absolutely deterministic execution. That’s not the case with UE4, as a big engine with a time-dependent game update model and reliance on a wide range of middleware and a wide range of platform and runtime OS-version and API-dependent optimizations. An engine could be designed this way, but UE wasn’t, and it’s not practicable to retrofit it for a special usage case.

Instead of lock-step determinism, I recommend working with the engine’s network replication framework. This code has fairly good performance and typical internet connections have plenty of bandwidth, so I expect it to be practical for RTS usage.

Also keep in mind that you can customize the engine’s relevancy checks (which determine whether a given object is replicated to a given client) based on the client’s view of the world, which will usually change fairly slowly in an RTS.

1 Like

Thanks for the answer !

[= Sweeney;275708]
This is a question that has been raised in every generation of the Unreal Engine, and it is definitely not in the works. Lock-step execution can only work if every engine system on every platform is designed for absolutely deterministic execution. That’s not the case with UE4, as a big engine with a time-dependent game update model and reliance on a wide range of middleware and a wide range of platform and runtime OS-version and API-dependent optimizations. An engine could be designed this way, but UE wasn’t, and it’s not practicable to retrofit it for a special usage case.
[/]

And this also means it’s not really possible, even for AAA developers, to implement this in UE4.

[= Sweeney;275708]
Instead of lock-step determinism, I recommend working with the engine’s network replication framework. This code has fairly good performance and typical internet connections have plenty of bandwidth, so I expect it to be practical for RTS usage.
[/]

Thanks for your “recommendation”, it’s just the only option we can choose :rolleyes: It’s nice to hear you think it’s practical for RTS usage, but most people I have talked with about this topic said it’s not possible to create a RTS with thousands of units with replication. I have not tried it yet since I think it’s hopeless.

[= Sweeney;275708]
Also keep in mind that you can customize the engine’s relevancy checks (which determine whether a given object is replicated to a given client) based on the client’s view of the world, which will usually change fairly slowly in an RTS.
[/]

RTS games usually have a small minimap where you can easily jump immediately to the opposite site of the map with just one click on the minimap. So the clients view can change really fast.

However, I remember this post from an Epic developer (April 2014):

[=John Pollard;9907]

  1. Send RPC’s from each client to server as they take turns to feed their input into a simulator that only runs on the server. Then use standard actor replication to each client, so they see what’s happening.

This would give you more room to decide if the simulator needs to be deterministic or not and easier to support late joins.

  1. Send RPC’s to server for each move, then forward these moves back to each client via multicast RPC’s. This would require a completely deterministic simulation running on all machines. It would also be more difficult to support late join. There wouldn’t be any major engine modifications though.

  2. Same as 2 except send RPC’s to all other machines in full mesh/lockstep fashion. This is probably the closest to the original lockstep model seen in doom but also the one that would be the most difficult and least flexible option. You would need to make some modifications to allow full mesh RPC’s for example.

#1 would be my vote as the engine would nicely support this, late joins are possible, and wouldn’t force you to use a deterministic model. You could still lockstep turns if you wanted but you don’t really need to do that either.
[/]

I find most interesting that he said option 2 would not require “any major engine modifications” while it would be “completely deterministic”. This is virtually the opposit of what you said, . Who is right now? Well, you are the “Master of UE4” so you are probably right, but I just want to have some hope :cool:

[=;275747]

And this also means it’s not really possible, even for AAA developers, to implement this in UE4.
…
I find most interesting that he said option 2 would not require “any major engine modifications” while it would be “completely deterministic”. This is virtually the opposit of what you said, . Who is right now? Well, you are the “Master of UE4” so you are probably right, but I just want to have some hope :cool:
[/]

You can do it in UE4, just like with Unity’s original network version I created a similar implementation back in 2008-2009. The problem here isn’t that much sending the data, the problem is keeping things deterministic (which I guess was 's point).

Having something be deterministic means that input A will always return output B (e.g. a path a unit chooses to follow, or how much damage you do, you can’t rely on floats), no matter the platform. In order to achieve this in our project back then we had to create a fixed point math (based on integers) that we’d use for everything in the game.

If you’re interested in following this path, I advise you to read these 2:

Also, in case you’re interested, here’s some of our stuff from back then:

BTW, as a side note, in the end this project morphed to something else. At the time doing the whole thing (without debugger, mind you, and for the browser plugin) was an insane task. We had our own network system (supported both mac & win, and back then that meant handle byte ordering when compacting data), math system (with some limitations), pathfinding system (based on Warcraft 3 iirc, can’t find any docs on it, sorry), and ai. At the time the project changed, we had the clients always in sync, what was biting in the *** was deadlocks when “large crowds” collided. Given that all this was done by 2 guys (shout out to Ramon Axelrod, without his guidance none of it would have happened), I was pretty amazed of how far we got.

Good luck with your endeavours!

Regards,
Nuno Afonso

Ideally in a lockstep RTS, you only send commands between the connected players using RPC and don’t replicate anything else. This is how I understand a game like Starcraft would work or Age of Empires based on that Archers over 28.8 K paper.

So would gameplay be deterministic even on UE4 if you handled a lot of logic using ints? Like damage, unit locations, etc? It might get a bit weird when you have unit positions that are stored as 3D transforms full of floats. You may have to store a unit’s true position in ints and use that for any gameplay logic. All movement and pathfinding and range calculations would have to take place in int space. Then force the actor’s transform to update based on the int position to update it visually.

I also remember reading that Supreme Commander still did things in floats but they disabled some CPU optimizations like SSE and that made the calculations deterministic as well. Maybe they compiled some of the gameplay into a dll with optimizations off while some of the other stuff that doesn’t affect game logic but benefits from optimizations like physics and graphics with them on. In an RTS physics would probably be only for pretty effects and explosions unlike in an FPS where the whole game depends on physics, so that may make sense.