7 ms·
It wasn't really that much to do with determinism. Quake uses a client-server network model all the time, even when you're only playing a local single-player ga
by ndepoel 5mo ago
It wasn't really that much to do with determinism. Quake uses a client-server network model all the time, even when you're only playing a local single-player game. What the demo recording system does is capture all of the network packets that are being sent from the server to the client. When playing back a demo, all the game has to do is run a client and replay the packets that it originally received from the server. It's a very elegant system that naturally flows out of the rather forward-looking decision to build the entire engine around a robust networking model.
- anonymous_sorry 5mo agoI don't see why it makes a difference for this purpose that you're replaying network packets or controller inputs or any other interface to the game engine. The important thing is that there is some well-defined interface. I guess designing for networked multiplayer does probably necessitate that, but if the engine isn't deterministic it still isn't going to work. There was a twitter thread years ago (which appears to be long gone) about how the SNES Pilot Wings pre-game demo was just a recording of controller inputs. For cartridges manufactured later in the game's life, a plane in the demo crashes rather than landing gracefully, due to a revised version of a chip in the cartridge. The inputs for the demo were never re-recorded, so the behaviour was off.
- ndepoel 5mo agoIt does make quite a big difference. The network packets received from the server in Quake will tell you exactly what state the game is in at any point in time. They contain information about the position and state of every entity and their motion, compressed via delta encoding. That means there's very little room for misinterpretation on the client side that would lead to de-sync issues. In fact clients have quite a lot of freedom in how they want to represent said game state, and can for example add animation interpolation to smoothen things out. The example you mention of demo playback de-syncing when the circumstances slightly change, that is exactly what you get when you only record inputs from the player. Doom actually did this too for its networking model and demo playback system. That relies much more on the engine being deterministic and the runtime environment behaving consistently, because each client that replays those inputs has to run the exact same game simulation, in order for the resulting game states to match.
- vvanders 5mo agoLook into dead reckoning vs lock step for networking. Lockstep requires determinism at the simulation layer, dead reckoning can be much more tolerant of differences and latency. Quake and most action games tend to be dead reckoning (with more modern ones including time rewind and some other neat tricks). Very common that replay/demo uses the network stack of it's present in a game.
- cubefox 5mo agoAn interesting thing about the a lockstep solution which only considers inputs is that any RNG required in the game must be generated from the input history somehow. This could lead to players being able to manipulate their luck with extremely precise inputs.
- mackman 5mo agoThe other interesting trick is you need a separate RNG for visual only affects such as particles than the one you use for the physics simulation. Depending on the game during replays, you could position the camera differently and then particle effects would render differently depend, depending on what’s on screen. Obviously that shouldn’t affect the way objects decide to break during the physics simulation.
- 10000truths 5mo ago> a lockstep solution which only considers inputs Nothing stops you from adding a PRNG seed parameter to initialize your deterministic game engine.
- cubefox 5mo agoThat could lead to other subtle problems elsewhere though, because it requires synchronizing the seed. If you can't do that, it could lead to problems. E.g. when comparing offline speedruns where everyone would have a different seed. Then some players could have more luck than others even with the same inputs, which would be unfair. (Though I can't think of anything else at the moment.)
- setr 5mo agoif its deterministic lockstep, then all you need to do is record inputs and replay the inputs, since the engine itself is guaranteed to behave the same. If it's client/server and non-deterministic, then you need to record the entire state of the system at every step (which you'll naturally receive from the server) to replay. The main difference would be in how large a replay file would get; and more dynamism naturally implies more information to record. Large unit quantities in e.g. an RTS behaves more sanely with deterministic replay. the other negative with deterministic input-based replay is what you've said -- if the engine deviates in any manner, the replay becomes invalidated. You'd have to probably ship with every version of the engine, and the replay just runs on the relevant release. Just replaying and re-recording the inputs on the new version wouldn't do anything, because the outcome behavior would inevitably out of sync with the original. I'm also not sure how one would support scrubbing, except by also having inverse operations defined for every action or by fully-capturing state at various snapshots and replaying forward at like 10x speed.
- forrestthewoods 5mo ago> I don't see why it makes a difference for this purpose that you're replaying network packets or controller input Building a simulation that has perfect determinism is incredibly time consuming. Incredibly. Especially one that is identical across platforms, chipsets, and architectures. Deterministic simulation replay also breaks anytime you change the simulation. Which is kind of obvious. But quite meaningful. In any case, I’ve shipped games that use both solutions. And let me tell you, deterministic simulation from input is an order of magnitude more effort to build, test, and maintain!
- vor_ 5mo agoUsing a client-server model for single-player allows it to lean on that system for replaying state changes.
- DANmode 5mo agoHN post linking to that Twitter thread! https://news.ycombinator.com/item?id=19883714 https://news.ycombinator.com/item?id=19883714
- _jackdk_ 5mo agoCarmack wrote a really interesting .plan about this. It seems to be written between Q2 and Q3A, and cites the Windows message queue as a big inspiration: https://github.com/ESWAT/john-carmack-plan-archive/blob/master/by_day/johnc_plan_19981014.txt https://github.com/ESWAT/john-carmack-plan-archive/blob/mast...
- kahrl 5mo ago[flagged]
- mackman 5mo agoInstant replays that require long-term deterministic behavior have to be bit perfect in a way that is dramatically hard harder to implement if trying to also do network synchronization. The hard parts of each of those is fundamentally different and trying to do them at the same time terrifies me. I have shipped console games doing both (independently) and was responsible for de-bugging determinism.
- kahrl 5mo ago[flagged]
- alfg 5mo agoIt's just capturing inputs and replaying them.
- furyofantares 5mo agoThat's not true though, is what they're saying. Quake demo files are server-to-client packets, results of the simulation, not client-to-server packets, the inputs. If you wanted to add random critical hits and random bullet spread based on the pixels in a live feed of a lava lamp cam, clients could still record .dem files and they would still work.
- syspec 5mo ago"All you have the game has to do is run the client and replay the packets" --- Sure after you build a sophisticated the system that supports that, then you "just" do as you described. EASY!
- Rohansi 5mo agoIt sounds like it would be complicated but it's really not! The server should already be sending a snapshot of the world when you connect and then stream deltas after that. If you capture all of the packets the server sends you can mock the connection to the server and it should just work because the client renders everything based on that data. You'll only need to do a bit of work to disable client input etc.
- Narishma 5mo agoI'm not sure that's the reason since Doom and Wolfenstein 3d before it also had such demo systems but they didn't use a client/server model.
- lelanthran 5mo agoIt doesn't need a client server model, but it does need a message pump design. Then you record the messages as they are recieved, and if networked, tx and rx the messages in the main pump loop. If not networked, everything still works as normal: game engine itself never knows the difference.
- Jare 5mo agoDoom and Wolf3d and many other multiplayer games of the 90s (including some I worked on) were deterministic/lockstep and machines only needed to exchange inputs (in a deterministic manner ofc). Quake was completely different. The client/server term was aimed at describing that the game state is computed on the server, updated based on client inputs send to the server, and then the game state is sent from server to the clients for display. Various optimizations apply. Deterministic/lockstep games more often used host/guest terminology to indicate that a machine was acting as coordinator/owner of the game, but none of them were serving state to others. This terminology is not strict and anyone could use those terms however they wanted, but it is a good ballpark.
- trashface 5mo agoThe engine needs to save the RNG seed too and various other details, the goal is definitely to make it as deterministic as possible (and yes saving the packets is part of that).
- andrewmcwatters 5mo ago[dead]
- vidalee 5mo agoLeague of Legends is using the same system