There’s something particularly upsetting about being hit by a green shell.

Red shells at least have the decency to announce their arrival. Red shells also have integrity enough to admit they are actually being steered: there is a prevailing belief that the nominally unguided green shells are in fact deflected towards players after recoiling from a wall. This unconfirmed phenomenon is nicknamed ‘smart-bouncing’, and may (along with a colossal hitbox) go some way to explaining why it’s so easy to hit *yourself* with a green shell.

In the chaos of the midfield, it’s often impractical to keep checking behind you for incoming green shells. So how best to avoid impact? In this post, I’ll present the results of a numerical model that predicts where along the track you are most likely to be hit.

The purpose of the model is to simulate a cart being bombarded by a large number (~10^{5}) of green shells launched with a narrow distribution of initial positions and velocities. The probability of the cart being hit is calculated by taking the ratio of the number of green shells that hit the cart to the number of shells fired. This calculation is carried out for a range of cart positions. Here’s how the program works.

Consider a straight track situated in the plane, as pictured in the diagram to the right. The edges of the track coincide with the lines . Somewhere on the track is a cart (depicted as a red circle) of radius with coordinates , constrained by and .

The program spawns a shell of radius somewhere on the line = 0. The shell’s -coordinate is chosen from a normal distribution zero mean and a standard deviation of about 0.5. The normal distribution is chosen because most players will drive somewhere close to, but not exactly along, the centre of the track, and so the shells they launch will have a narrow distribution of positions.

A line connecting the shell to the cart is then drawn (rendered in red). The program then generates a ‘deflection angle’ , once again chosen with zero mean and some standard deviation . The line segment connecting the shell and cart is rotated about the shell through this angle, and the shell is subsequently launched along this line (drawn in green). This is done to ensure the attacker only has finite accuracy: the larger , the less accurate they are.

With the initial position and velocity of the shell specified, the program can subsequently solve for the shell’s trajectory. The shell is assumed to experience zero acceleration for all time, apart from when it encounters either of the track edges, in which case its -component of velocity is reversed (that is, we neglect smart-bouncing). The shell’s coordinates are propagated through time until i) it collides with the cart or ii) its -coordinate exceeds (i.e. it is guaranteed to have missed).

The procedure above is repeated = 100 000 times. The hit rate is calculated by dividing the total number of successful hits by . The program then shifts the cart’s -coordinate by some small amount, and the entire process repeats. The result is a hit rate curve describing how likely you are to be hit depending on how far along the track you are.

The parameters used for this models were: = 3, = 0.050 and = 0.075. The graph below displays the hit rate as a function of . The number next to each curve denotes .

We first notice that the greater , the lower the average hit rate; this should not be surprising. We also see that, for high accuracy, there is a very little variation of the hit rate with . However, something interesting happens as the attacker’s accuracy decreases: sharp maxima appear a roughly midway between the track centre and its edges. What’s going on here?

The diagram below shows traces of shells fired at a cart in three positions from left to right: at the track centre, midway between the centre and the edge, and at the edge. White rays indicate those shells that miss the cart, green those that hit. We have set to zero for clarity.

The leftmost pane shows traces of shells fired at a cart on the track centre. This defines our baseline hit rate, with no complications being caused by the track edges.

The central pane shows traces of shells fired at a cart midway between the track centre and edge. The traces make it clear that a* *greater percentage of the shells fired collide with the cart. Why? Because it is now possible for shells that would otherwise miss the cart to collide with the track edge before landing a successful hit.

The rightmost pane shows traces of shells fired at a card at the track edge. Conversely, the hit rate here is fractionally *diminished*, for the following reason: shells that would otherwise strike the cart on its left-hand side are deflected by the track edge, and narrowly miss the cart on its right-hand side.

This discussion provides the intuition as to why there should exist maxima in the hit rate curve. Can we make a quantitative prediction of where exactly these maxima occur? The central pane about shows that, for a cart between the track centre and one of the maxima, there is a ‘shadow’ in the angle distribution where shells pass between the cart and the track edge; shells launched with smaller are able to hit the cart directly, while those with larger rebound from the wall first. As the cart moves closer to the maximum, you can imagine this shadow closing up, eventually reaching the point where a shell can *only **just* pass between the cart and the track edge. If the cart moves even a little nearer the track edge, the shadow suddenly vanishes. *This *must be when the hit rate rushes up to its maximal value.

If you’re so inclined, you can find the precise value of at which a shell is only just able to pass between the cart and the track edge. The value is a solution of the quadratic equation

You can show that, if , the solution reduces to

Simply put, this says that **the most dangerous place to drive is where your cart’s edge is exactly one shell’s diameter from the track edge .**

*These positions have been indicated on the hit rate graph by the vertical dashed lines; you can see they predict the locations of the maxima very well!*

So, the moral of the story is this: driving down the middle of the track is actually not too bad a strategy if you want to avoid unseen green shells. Generally, the nearer the edge of the track you are, the more likely you are to be hit by rebounding shells. Of course, you can also invert this reasoning, and conclude that, if you are armed with green shells, you should wait for the person in front of you to drift towards the edge of the track before firing.

I hope this advice serves you well. Happy karting!