Formula XD
Game Development Journal
Ruddy Terrorists

Pitlanes and pit crews and bombs, oh my!

11th March, 2017

Something that bugs me a little is how easily it is for me to forget what I’ve been working on very quickly, and it’s probably because there’s so much going on that there’s no time to reflect. Except, of course, on weekends, which is why I keep up this journal. So, having wrapped up making a bunch of circuits last month, what have I been up to in the first full week of March? Well, I wasn’t sure myself, so I read my last week’s Twitter posts to remind myself. Here’s what I found out, and boy there’s a lot.

The first job of the week was to finish plugging all the circuits into the game. Fairly straightforward, there weren’t many left to do. It then occurred to me to finally improve the pitlane pathfinding system by adding some more nodes and making splines out of them. Fortunately, after making a big mess and breaking stuff on Monday, I got it all figured out and working on Tuesday, so pitlane movement is now a lot smoother. There’s still a bit of work to be done on regulating the speed at which cars travel through it, but it’s fairly trivial.

There was a lot of testing to do on Wednesday, going through each of the 24 circuits in turn to make sure they were all behaving properly. This exposed some curious little problems – fuel leaks, fuel over-retention, safety car not parking properly, cars going backwards and forwards out of the pitlane, sudden bursts of speed – but most of them were fixed by the next day. My only regret is that worrying about fixing that lot kind of distracted me from something else I really wish had gone better.

Eh. Well. Anyway. That night I also started testing the new game feature for Jihadistani Grands Prix: bombs laid by terrorists who would rather people didn’t race cars about the place. On Tuesday I’d come up with an explosion animation, and sourced a couple of sound effects to go with it.

What I didn’t expect was that, after plugging all the relevant bits and pieces into the game engine, the first bomb would almost give me a heart attack and kill me as a cruel and ironic twist of fate (hyperbole alert). The volume needed to go down a bit on that one. Then it turned out that the bombs had been made too sensitive, so about ten bombs went off in the span of about thirty seconds. Now that was funny.

Of course, all these bombs going off attracted the attention of the safety car, and that also needed some work. Sometimes, cars were even overtaking the safety car! The nerve! So I went in and adjusted the feedback loop for cars reacting to the safety car. I’m not sure if that’s enough, yet, I haven’t got round to a proper stress-test yet.

On Thursday, I had a bit of an idea for France’s gimmick. Previously, the race would go on as usual and then after the fact, officials would seek to disqualify any English driver who finishes ahead of a French driver. This is one of those things I’d been meaning to replace for some time; it’s simply not fun, and it comes across as a little mean-spirited.

This new idea I came up with instead was rather more playful: French race officials banning any team communications not conducted in the French language. So when your driver pops up with a notification, French or Canadian drivers relate their problems in French, whereas any other drivers attempt to inform you of their situations in a kind of broken half-French. This makes it more difficult, but not impossible, to read feedback from your drivers, and certainly has more comedy potential than a vanilla race followed by a bogus penalty.

That afternoon, something I noticed was that the player’s pit crew seemed to be working miraculously quickly. This was particularly jarring because, when I wrote the pit crew code months and months ago, I took great pains to do the maths to accurately simulate how long a pitstop would take, according to how well-equipped the pit crew is.

Let me explain. In Formula XD, you can spend between £50,000 and £1,000,000 on training and equipping a pit crew over a season. For £1,000,000, you get a full crew of dedicated professionals, and the less you spend the less talent you can afford, until you get to £50,000 and all you’ve got is a single “gullible volunteer”.

I established a baseline of five seconds, assuming that an ideal pit crew would have a car’s tyres all changed in roughly that time. (paying no heed to the truly superhuman advances in pitstops from Formula 1 in recent years, with Williams F1 pulling off a stunning 1.92-second stop last year).

And then, to determine how long it would take for a single person to do everything – operate the jacks, change the wheels, operate the fuel pump, clean the driver’s visor – I stopped my startwatch and ran all around the living room, playing out the various actions. Yes, ladies and gentlemen, for art’s sake I actually did that. A few repeats established a time of between 45 to 50 seconds, so that was my other target, at the other end of the scale.

To get a nice exponential curvy line from 5 seconds (a million quid) to 50 seconds (fifty grand), I sat down and did lots of maths until I came up with the following equation:

t = (1/(√(£/1000)-4)) x 100

From there you’d take “t” as the base, and add a random number between 0 and “t” to produce a plausible variety to pitstop times. One of the pros might get the pneumatic hubnut gun thing a bit stuck, or our friend the gullible volunteer might lose a wheel and have to go running after it, for instance.

Before you ask, no I don’t remember why the -4 part is so important. I lost the piece of paper that I worked it all out on, and since the equation works, it seems like folly to chuck that part out.

Right, anyway, it took a bit of sniffing around to find the problem, and it turned out that my team had started the season with a pit crew budget of £0. If you apply the equation, t comes out as -25, and the bit of the code that works out pitstops doesn’t really figure with negative numbers, resulting in an infinitesimally short pitstop. So that was pretty straightforward in the end.

On Friday – and this was essentially the last thing I did this week – I had a bit of work to do with the testing/qualifying phase of the game.

Firstly, a long-standing problem with the testing tracker, which shows you a bar-style visual indicator for how much of a test has been completed. It’s rather difficult to explain how it works because of how involved it all is, but put simply, it would break when a car went into the pits in the middle of a test. There was a terrific bit of maths which decided how full the bar would be, but it needed a couple of additional conditionals to work. A bit of a head-scratcher, but nothing like what I’d feared.

Secondly, there had always been a game design problem with testing/qualifying. The idea was to establish a dichotomy between setting good qualifying times, and running R&D tests, so the player would have to make meaningful choices between short term advantage (better grid position for the first race) and long term gain (a slightly better car for the whole season).

However, you could quite easily set fast lap times while out on a test run, making it a false dichotomy. The solution was to prohibit the use of soft tyres and the attack button while running a test. The justification is fairly obvious; tests require consistency, and fast-degrading tyres and a manic driving style don’t exactly exude consistency. So I did that. Yeah. It wasn’t difficult, that bit, just took a bit of time.

And that’s all there was, apart from some GUI tidying. In hindsight, this has been quite a busy week! Well, next week will be somewhat more mundane. I’ll be expanding support for multiple screen resolutions.

Until next time!

Leave a Reply