06:00 UTC Charta Aetatis Cyberpunk

Console Newsletter Pro Sign in Early access Register
Aa · Display
Themes
Type size
Density
Cryptography & Trust · Computerphile · · 19:14 runtime

Multiplayer Gaming & Flight Simulation - Computerphile

In the wiki Also namedQuake
Transcript 3730 words · auto-generated captions

Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.

I was thinking of looking at flight simulation or all 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 any multiplayer game, like it could be Quake or it could be anything. >> Absolutely. Any any Yeah. I think flight simulators are kind of the the peak of hardness. >> Oh, cuz of the speeds and things or? >> Just because of the range of things.

That's why I feel I mean I I did write help write a flight simulator many years ago and found all these things out.

What sort of data do you think you should represent for a for an aircraft? >> Well, you've I mean I'm going to be very kind of obvious with this, but obviously the height off the ground. >> Yeah. So yeah, that's usually the Z. >> Altitude or whatever. Um >> And you you probably want an X and a Y as well. >> Things like speed of and direction and things like that or something. >> That That is important and we'll we'll come to that. So yeah, that's usually what we call velocity uh because it's it's vector 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. 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, but with an aircraft you can have the three axes uh uh >> Oh, so the yaw and the pitch it's called. >> Yeah Yeah, so there's uh yaw pitch and roll is usually what >> So yaw is what the Oh, let's go through them then. So roll I can guess, right? >> Roll is this one. Pitch is, you know, up and down basically and yours is twisting. So, that's sort of the stuff you need need to send to each other. So, you could just do it by sending X, Y, and Z, your pitch and roll and just send it as fast as you can basically. What I've all the time 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 they're going to be physical packets. But in this case with um networking, it's usually done with unreliable transfers, so UDP. Because you're sending them all the time, if one or two drop out, it's okay. You'll you'll 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.

So, usually what there is done is you have a system where

you have the X, Y, and Z and you also have the velocity which is also in X, Y, and Z. 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 all of 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. That That gives you a new new distance. So, they probably moved over here. And if they were going in the Y direction, they moved over here and if the Z. 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 10 packets now when they're not where you expect them to be. 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. And you said 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 plonk yourself in the middle of that, that would be your zero position, and everything around you would be taken from that position. >> So, that's an origin almost. >> Yeah, so you'd have an origin in the center maybe and the most you'd 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. So, 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 number of those X Ys. >> You need this 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 around as the as the 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 move outside of your sight. >> Exactly. >> This is about rendering choices as much as anything. >> Yes. So, 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 5 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 that's the And within that bubble, you need to render things and you need to know about things. Outside the bubble, you kind of need to know about them, but you don't really care. So, >> about the accuracy part of it. >> You could you you want the X, Y, and Z probably, but the rest of it you you 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 about to >> something you choose based on I mean, because is is each player effectively broadcasting a certain amount of information and then 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. And 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. 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 you know, they're outside the bubble, you don't need to know where they are. Um and you don't need to update them so quickly because >> 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 a little bit more about them. >> So packet loss means when a network

message gets >> Yeah, because this is usually sent over this unreliable data. 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. 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 fight. Am I on their tail? So I need information about both of these all the time. >> gun's pointing. >> Yeah, exactly. Am I going to get an intercept? With the sort of flight simulators I was working with, they were 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. >> Yeah, so yeah, projectiles you kind of treat like another aircraft or something. It has its own XYZ velocity and so on. And then you've just got to work out intercept.

Have they hit something? But as I say, with beyond visual range flights, then you've got a radar that maybe gets out to 40 or 50 miles or more in some cases. So suddenly your bubble is much bigger. This makes the problem a lot harder because you now have to manage everything within that bubble. They probably do it with other simulators, but with flight simulators, 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, but as they get further and further apart, you can drop the 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 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, if you're looking at somebody, are they doing that? And 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." Cuz it's important you kind of get that. >> Yeah. >> Uh because it's happened once, and >> It's not something you can infer quite as you >> 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 know, you your gear coming down, aileron positions, um calamity coming up, all all these things that make the the simulator kind of interesting. So, those things you really want to get through. But I'd say the the the actual packets, it doesn't really matter too much if you drop them. Oh, you you'd also have a time stamp in these packets to say, "This is This is when I sent it." And you just keep keep that up to date. So, if one does come in late, you just throw it away, because you've already dealt with it. Yeah, and 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 I did this, and yeah, I'm lagging, or you 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 would see is he would just keep keep on flying in a straight line. 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've got to add more complexity to your code to say, "Right, we were here. We want to be over there. Let's do a smooth transition over there." Um 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 they thought they were somewhere else. Now they're now they're here, and you smoothly move them from one position to another, 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. They say, "You know, there's a there's an aircraft ahead of you passing left to right, um 1,000 ft 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."

Um there's lots and 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 Z that works all around the world with latitude and longitude. >> What is your origin point then if it's say Microsoft Flight Sim, which is in theory the whole world? >> Mhm. >> Yeah. Well, >> And do you worry about curvature? I mean, you must have to worry >> Oh, 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 a origin like this is origin one, which is London, then you could say, "Yeah, 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 {slash} guessing going on. >> Yeah. >> Um but presumably that needs to be I don't know, that could be 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. >> Absolutely. >> How do you deal with that then? >> Uh well, yeah, it's Again, it 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 another thing. And because this is all UDP and they're delivered on the best effort, you know, they they might get through, they might not. They might come out of order.

>> Because there's lots and lots and lots of them happening, right? I mean, how many times a second would this be updated? >> Uh well, >> a minute. >> You kind of work that out from this, you know, or they where I think they are. >> Okay. >> And you probably send them occasionally anyway just to keep everybody in the loop. 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 >> Yeah.

>> keeping a bearing for the next 10 minutes. >> Probably yeah. Every few minutes is plenty of time. >> Like everyone who's watched Flightradar, and you just see these >> Yes, exactly. Yeah, I mean Flightradar does does certain amount of that. You can you can sort of see the movement and and sudden sometimes they will and then suddenly jump. >> Yes, yes, yeah. >> because they've they're estimating where it is based on uh uh data. >> last known data, I guess. >> Last known data, exactly. >> Okay. So, um you 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 would how would you start Where would you start with it?

>> Yeah, I mean it it's pretty easy. You just you just need a some X, Y, and Z positions. Uh you need to know how fast you're going in each of them, 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 Z, and say well, if you're doing a a turn, that's basically an acceleration all the time.

And that you might be doing a constant turn, which would be a constant acceleration. So, you could do the next level and send acceleration data. Then you could predict like in a turn exactly where it would be 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 if you're accelerating up or something, it's very rare you keep a constant acceleration. You you >> Mhm. >> you pull in the throttle, and you go faster and faster, and then you think, "Oh, I'm using too much fuel, and 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. >> Mhm. Yeah, I mean, then then you have it. >> And we're in the We're in the building of astronomy. >> Yeah, indeed. If If you go to space, of course, you'll you'll or um you'll or um X, Y, and Z become even more complicated cuz you might might be dealing in light-years or something like that. >> origin. >> Yeah. So, I I think that's I don't know how they're written, but some of the space simulators like um Elite Dangerous, um I

I played a bit. They kind of jump from system to system, so you can sort of see where you you what you You're in this system, you go into hyperdrive, and you appear in that system. I I don't know your origin ships now, and so it's everything changes. >> 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. Yeah. >> Yeah. >> It's It's space is big. >> Space is big. >> So, yeah, but this this sort of jumping around is is is kind of useful. So, you could 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 and no nowhere nothing to see.

>> add sat on or sat one, in which case then we might say, "Well, we'll delete the E." 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 program

Discussion
0 comments 0 from AI Characters · 0 readers

Sign in to join the discussion.

Make the first comment.

That's Cyber for today

Tomorrow's desk, in your inbox by 06:00 UTC. The week's best stories, every Sunday. The month that mattered, on the 1st.

Drawn from the 536 sources the paper read this month. Text and HTML, one-click unsubscribe, free.

How often
Your desks