← All transcripts

Multiplayer Gaming & Flight Simulation - Computerphile Transcript, AI Summary & Key Points

Computerphile · 28 days ago · Education · 19:14 · EN-GB

Watch on YouTube

AI Summary

Multiplayer flight simulation is the hardest case for sharing player state between machines: each machine must know every other player's position, velocity and attitude. Sending full state (X, Y, Z, pitch, roll, yaw) constantly over UDP works but is too expensive with many players, so flight simulators send position plus velocity and extrapolate (dead reckoning), only transmitting updates when a plane departs from where the other side expects it to be. A client-server architecture gives each player an 'interest bubble' — distant aircraft only need coarse X/Y/Z data, close ones need full detail including aileron positions, landing gear, canopy and lights, with rare one-shot events like lights sent over reliable TCP. World-scale coordinates need double precision or hybrid multi-origin systems (e.g. an origin at London with offsets), and late packets are discarded using timestamps while visual glitches are smoothed by interpolating toward new positions rather than teleporting.

Key Points

  • Aircraft multiplayer state requires X, Y, Z position, velocity (a vector in X, Y, Z), and attitude — roll, pitch and yaw — unlike a car or train simulator which mostly needs only X and Y.
  • The naive approach is to send full state as fast as possible over UDP; unreliable transfer is fine because if a packet drops, the next one arrives, but it becomes very expensive with 20 players.
  • Dead reckoning cuts traffic: each machine stores position plus velocity and extrapolates the other player's position (new position = position + velocity × time), so packets are only sent when a plane is not where it is expected to be; the sender runs the same check and skips updates that the receiver could compute itself.
  • Violent manoeuvres like dogfights need updates every few milliseconds, while an airliner on a steady Atlantic bearing may only need an update every few minutes.
  • A client-server model beats broadcasting: the server decides what to send each player, giving each a bubble of high-accuracy interest; outside the bubble only rough position matters, mirroring how air traffic control only reports the aircraft relevant to you.
  • Modern simulators with beyond-visual-range weapons have radar reaching 40–50 miles or more, which enlarges the bubble and makes the problem much harder; projectiles are treated like another aircraft with their own position and velocity for intercept calculations.
  • Level of detail scales with distance: full detail close up (including aileron positions, landing gear, canopy, navigation lights), reduced triangle count further away, and just a dot at extreme range.
  • Infrequent, non-inferable events like switching lights on or lowering gear go over reliable TCP because they happen once and cannot be inferred from repeated packets.

Tools & resources

2 items

Links mentioned

🔒 Full analysis locked

Unlock more videos and the full analysis

A credit unlocks one video's full analysis for good — the build steps, the tools and how each was used, the methods behind every use case. Pro opens the whole library instead, and raises how many videos you can analyse a day.

Unlock full analysis — free

Transcript

Searchable transcript of Multiplayer Gaming & Flight Simulation - Computerphile — Computerphile (19:14). Search for a phrase, then click its timestamp to jump straight to that moment in the video.

Captions sourced from the original video on YouTube, published by Computerphile. The video, its captions and all related intellectual property remain the property of their respective owners; AINotes claims no ownership. Provided for research, accessibility and search — see the Transcript Notice and Copyright Policy.

00:00 I was thinking of looking at uh flight simulation or or general simulation but but really the sharing of the data. I want to know where you are. You want to know where I am so that we can project something onto a screen and and we can see each other and there's lots and lots of ways of doing this but so we'll go through a few. >> So like uh any multiplayer game like it could be Quake or >> absolutely any Yeah.

00:20 I think flight simulators are kind of the the peak of hardness >> or because of the speeds and things or >> just because of the range of things. That's why I feel you know I I did write help write a flight simulator many years ago and found found all these things out. >> What sort of data do you think you should represent for a for an aircraft or >> Well, you've I mean I'm going to be very kind of obvious with this but obviously the height off the ground.

00:50 >> Yeah. So yeah, that's usually the >> altitude or whatever. Um, >> and you you probably want an X and a Y as well. >> Things like speed of D and direction and things like that or >> that is important and we we'll come to that. So yeah, that's usually what we call velocity. Uh because it's it's vect quantity going in different directions. This is why I sort of think flight simulators are kind of interesting because if you're doing a car really, you probably only need the X and the Y for most of the time.

01:16 you might occasionally catch air or something like that, but but it it's kind of limited. If it's like a train similar, you know, that's probably only X and Y, but with with this one, you definitely need the Z axis because you have the altitude. >> The other thing with um an aircraft is you need the attitude. So with a car, you know, with >> Oh, the direction >> you turn like this.

01:40 >> But with an aircraft, you can have the three axes. >> Oh, so the y and the pitch it's called. >> Yes. So there's your Your pitch and roll is usually what? >> So your is what the Oh, let's go through them then. So roll I can guess >> roll is this one. Pitch is you know up and down basically and your is twisting. So that's sort of the stuff you need need to send to each other.

02:03 So you could just do it by sending X Y and Zed your pitch and roll and just send it as fast as you can basically all the time. all the time and and you would know kind of where where these were. >> That's a little expensive in in network terms. And you also need to consider how you're going to send it. That's that's another thing. I mean, they're going to be physical packets, >> but in this case with um networking, it's usually done with unreliable transfers.

02:32 So, UDP, because you're sending them all the time, if one or two drop out, it's okay. You you pick up the next one. So that that's kind of what you do. But you know that is really expensive to send it all the time and especially when you've got more than two people. >> You've got like 20 people that's a lot of packets you're sending out all the time.

02:53 So usually what is done is you have a system where you have the x y and zed and you also have the velocity uh which is also in x y and zed. So, you know how fast you're going in this direction, that direction, and and up and down. And a lot of the time, not not all the time, but a lot of the time, you're going along at a constant speed. >> So, you can actually interpolate that and say, well, if I don't know anything else, the last time they were at this x position, I'll add on uh the velocity times time.

03:32 That that gives you a new distance. So, they probably moved over here. And if they were going in the Y direction, they moved over here and the zed. So you can sort of guess that um this is where they would probably be if I haven't heard from them in a while. That sort of smooths things out quite nicely because you you only need to send packets now when they're not where you expect them to be.

03:57 >> So on the sending side, you can also run the same thing. You can say this is where I am. I know what my velocity is. And if I do the same calculation here and say, okay, this this is since the last time I sent it, add these things together. Is that still where I am or is it close enough to where I am? And if it is, I won't bother sending it out because they could work that out.

04:19 And you just keep going and going until you start doing a turn or something and then you say, "Oh, okay. This is all wrong. I'm going to have to send off new things." So that's kind of how you synchronize the these things. Uh, another of the big problems with flight simulators, I mean, if if you were doing like a a racing simulator, you'd go to, I don't know, Silverstone or somewhere, you'd plunk yourself in the middle of that.

04:46 That would be your zero position, and everything around you would be taken from that position. >> So, like an origin almost. >> Yeah. So, you'd have an origin in the center, maybe. And the most you'll probably need is a couple of miles in each direction. You're not going to take your Formula 1 car down the >> You've left the map, >> the M1 or something like that.

05:04 In the flight simulator, of course, you're not really constrained there. You can take off and you can fly off in any direction. You need a bit more sophistication in your coordinates and often floating point is kind of where you start, but that that is not always good enough. So like the accuracy of the the literal the numbers of those XY >> Z you need the the scale to you know cross countries or even the world and also if you're flying you know close to each other you you don't want to keep sort of jittering jittering

05:35 around as the as the uh floating point rounds up. Those are a couple of the the issues with it. Uh, another problem is because it's such a big scale, you know, we could be miles and miles and miles apart and do I really need to know about you at this point >> if you sort of almost outside of your site? >> Exactly. >> This is about rendering choices as much as anything.

06:02 >> So that there's a lot of that comes into it. I mean, if you were doing First World War type simulator, you could only see to like five or 10 miles at most before everything just fades into into nothing. So, that's another scheme where you you you tend to have yourself here and you have a bubble around you and within that bubble you need to render things and you need to know about things.

06:30 outside the bubble, you kind of need to know about them, but you don't really care. So, you >> care about the accuracy quite >> you could you you want the X, Y, and Zed probably, but the rest of it you you can't really tell whether this this plane is pitching up or down because it's so far away. So you can discard quite a lot of this stuff and just just go with this until this gets close enough that it's kind of >> is that something you choose based on because is is each player effectively broadcasting a certain amount

06:58 of information and you decide to throw some of it away? >> Usually it's done client server. You you can you know broadcast it to everybody but it's better if the server gets it and decides what to send out to each of the players. So they would each have a bubble around them. I did a quick simulation of how how this would look. It's viewed from pilot one basically looking at all the others and there is a kind of a circle in it which is the bubble in which they sit.

07:25 So that's where you want the accurate stuff and you can sort of see that the tracking is much more accurate within that. I I set the packet loss to be quite high just just to prove a point, but as you go further out, you can see them drifting a long way out of um out of position. That's partly because they're outside the bubble. You don't need to know where they are.

07:49 Um and you don't need to update them so quickly because you >> you know there's someone roughly over there. >> Someone over there. And that's all I need to know. there's somebody right way, you know, when they get within weapons range, I'll need to know little bit more about them. >> So, packet loss means when a network uh message get >> Yeah. Because this is usually sent over this unreliable data.

08:12 They may get there or they may not, but they're really cheap to send. So, you can keep sending them out. The network has no compunction about throwing them away if it gets under load. Uh so, that's that's kind of where that that stuff comes from. So you may lose quite a few of these packets and the server may equally not bother sending enough out if it's busy doing other things then says well that's a lower priority thing I don't need to keep that so up to date what they're really concerned about is you know the dog

08:43 fire am I on their tail so I need information about both of these >> direction are my guns pointing >> yeah exactly am I going to get an intercept with the sort of flight simulators I was working with more modern ones And now you have like beyond visual range weapons. >> And all of these things add an extra layer, don't they? Sending projectiles out.

09:03 >> Yeah. So yeah, projectiles you kind of treat like another aircraft or something. It has its own XY Z velocity and so on. And then you've just got to work out intercept. Have they hit something? But I say with the odd visual range flights, then you got a radar that maybe gets out to 40 or 50 miles or or more in some cases. So suddenly your bubble is much bigger.

09:23 This makes the problem a lot harder because you've now got to manage everything within that bubble. They probably do it with other simulators, but with flight simulators that there's kind of ranges of this so you have level levels of detail. So if you're flying right next to each other, then you kind of need to render both of these in their full detail.

09:42 But as they get further and further apart, you can drop the um the triangle count basically and say just an impression of the aircraft at this point is good enough. And when you get really far away, it it's just a dot. So you you just draw a dot and you don't. So that's why you don't need kind of so much your pitch and roll. But if you get really close, you might want to know about aileron positions.

10:07 If you're looking at somebody, are they doing that? Landing gear coming down, going up, navigation lights, and so on. But they're often they're kind of less frequent events. So you turn on your lights, they'll probably stay on for a while. You turn them off again. So sometimes those are sent by more reliable things like a TCP stream saying, "I've switched my lights on."

10:32 >> Because it's important you kind of get that. >> Yeah. >> Uh because it's happened once and >> it's not something you can infer quite >> right. So it's not going to happen again until they switch them off or or something like that. So there's some things like that and you your your gear coming down, aileron positions, >> um canopy coming up, all all these things that make uh the the simulator kind of interesting.

10:58 So those things you really want to get through. But I say the the uh the actual packets, it doesn't really matter too much if you drop them. Oh, you'd also have a time stamp in these packets to say this is this is when I sent it. Uh and you just keep keep that up to date. If one does come in late, you just throw it away because you've already dealt with it.

11:19 Yeah, that's where kind of latency and and things like that come in. And that's that's what players complain about. You know, I I did this and yeah, I'm lagging. You're not where you are. And one of the effects is if you have the network drop out. Um, so you would see that this guy might be doing that, but what we see is he would just keep keep on flying in a straight line.

11:44 And then there's also what do you do when you finally get an update? You could jump suddenly to the new place, but that looks kind of um >> Yeah. >> Yeah, absolutely. So, you probably interpolate and say, "Right, I I need to be over there, but I'm not going to do it in one go. I'm going to >> smoothly move over there over time." >> So, again, you got to add more complexity to your code to say, >> "Right, we were here.

12:11 We want to be over there. Let's do a smooth transition over there. >> Which does lead to odd effects sometimes. You you sometimes see if you're sitting on the tarmac, you sometimes see planes rise up out of the ground because uh they thought they were somewhere else and they're now they're here and you smoothly move them from one position to another.

12:32 But this bubble thing um lets you work out some of the details and it and it's quite realistic I guess to real life in some uh respects. You know, if you're flying along in a in a aircraft, you're talking to air traffic control. They're not going to tell you about all the aircraft around you. They're going to tell you about the ones that are important to you.

12:56 They say there's a there's an aircraft ahead of you passing left to right um thousand feet below you, but there's there's loads of stuff behind you that you you don't really care about. So that's kind of what this bubble is. It's saying this is kind of all the stuff you need to know. And there's lots of tricks you can play with this. um the precision you really need like double precision maths to give you the x y and zed that works all around the world with latitude and longitude >> what is your origin point then if

13:28 it's say Microsoft flight sim which is in theory the whole world >> yeah well >> and do you worry about curvature I mean you must have to worry about >> oh yes yeah you have to worry about all those things they do a hybrid system so they would have several sort of origins and And within the packet you you'd have origin like this is origin one which is London.

13:53 Then you could say yeah I'm I'm here and offset from this position >> and then you get a lot better precision from that. >> We mentioned before that there'd be a maybe a certain amount of inferring guessing going on. >> Yeah. Um, but presumably that needs to be I don't know that could that could be kind of like slightly out or slightly wrong depending on everything from network traffic to changes that the aircraft might make before it lets you know.

14:21 >> Absolutely. >> How do you deal with that then? Uh well, yeah, it's again it's kind of tricky, but you so you you can lose positional packets and just not get any. And that's when this this aircraft just flies straight along. Sometimes the program has crashed. They're never going to get another thing. And because this is all UDP and they're delivered on the best effort, you know, they might get through, they might not.

14:45 They might come out of all >> because there's lots and lots and lots of them happening, right? Yeah. >> I mean, how many times a second would this be updated? >> Uh, how many times a minute? >> You kind of work that out from this, you know, are they where I think they are. >> Okay. >> And you probably send them occasionally anyway just to keep everybody in the loop.

15:04 But, um, yeah, if you're doing sort of violent maneuvers like a dog fight, then they're going to come out every few milliseconds because you you really need to track exactly where they are so you can, you know, get on their tail and and all the rest of it. >> But if it's a a liner going across the Atlantic, keeping a bearing for the next 10 minutes, >> pro probably every few minutes is plenty of time.

15:28 >> Like everyone who's watched flight radar and you just see these >> Yes. Exactly. Yeah. I mean flight radar does does certain amount of that. You can sort of see the movement and sudden some sometimes they will and then suddenly jump. >> Yes. Yeah. >> Because they they're estimating where it is based on data. >> Last last known data I guess. >> Last known data.

15:46 Exactly. >> Okay. Okay. So um you've you've obviously done stuff to do with writing these and things. Is this something people could have a go at themselves and how how would you where would you start with it? >> Yeah. I mean it it's pretty easy. You just you just need some x, y, and zed positions. Uh you need to know how fast you're going in each of them.

16:06 And then it's just just really simple. You you take the x uh you add on um velocity in x times the time time interval. That's it's like a a delta time. >> So that that would give you your new x position. And you keep doing that for as long as you like. Mhm. >> You can take this to another level which is you can take the next component of this which is the acceleration in x y and zed and say well if you're doing a a turn that's basic acceleration all the time and you might be doing a constant turn which would be a

16:43 constant acceleration. So you could do the next level and send acceleration data. And then you could predict like in a turn exactly where people would. >> Uh on the times I've tried this out you most of the time it it doesn't really >> Is that because of network problems rather than >> No, I think it's more because you know if you're accelerating up or something it's very rare you keep a constant acceleration.

17:11 You you you pull in the throttle and you go faster and faster and then you think I'm using too much fuel. I'm going to level out. So you're all the time changing that sort of thing if if you're going to accelerate >> and when when you're moving along obviously there's straight along there's no acceleration anyway so that all those terms go to zero. >> I wonder if this would be much different if it was a space related thing or rocket tree.

17:36 >> Yeah. I mean then there you have it. >> We're in the we're in the building of astronomy. >> Yeah indeed. If if you go to space, of course, your your um your X, Y, and Zed become even more complicated because you might be dealing in light years or something like that. >> Yeah. So, I I think that's I I don't know how they're written, but some of the space simulators like um Elite Dangerous um I played a bit.

18:02 They kind of jump from system to system. So you can sort of see where you know you you you're in this system, >> you go into a hyperdrive and you appear in that system. >> I imagine your origin shifts now and >> it's a neat way of going around it. But also I've once or twice played Elite Dangerous and it takes so so long to get anywhere that actually >> That's right.

18:25 Yeah. Yeah. >> And space is big. >> Space is big. >> So yeah, this this sort of jumping around is is is kind of useful. So you can you can kind of get these hints of of what you do. And obviously, you know, if you fly for long enough in Elite Dangerous, it gets really boring because there's just open space and nowhere >> nothing to see. Add sat on or sat one in which case then we might say, well, we'll delete the E.

19:03 So we would have another object on here um which would be delete and then E and then again all these would store the location. Now, as we said, you would need to