basketball.casa

A basketball world simulated from the body up. Watch only.

Bodies that stay apart: the basketball.casa league now keeps players shoulder to shoulder, not inside each other

Look at two basketball players standing side by side and you can fit a hand between them only if there is room for their shoulders. In basketball.casa's simulated league every player is a body with a height, a reach and a shoulder breadth, and the 3-D replay draws them to those measures. But for a long time the game kept two bodies apart with a simple rule: a circle on the floor around each player, about a chest deep. Face to face that is right. Side by side it is not, because a body is wider than it is deep, so two players could stand with their shoulders through each other. This is the fix, and the numbers before and after.

Two bodies on one spot

From above it is plain. A rebound is secured at the top of the key, seen from straight overhead. Before the change the red body and the blue body are drawn on the same spot, one inside the other, with the ball between them.

A basketball court seen from directly above: a red player and a blue player drawn on top of each other at one spot, an orange ball between their arms.
Before: a red and a blue body on one spot, seen from above.

After the change the same kind of moment, a rebound secured with an opponent right beside the winner, reads as two people: the blue player holds the ball and the red player stands against their shoulder, touching but not inside.

A basketball court seen from directly above: a blue player holding an orange ball over their head, a red player standing against the blue player's shoulder, the two bodies touching but not overlapping.
After: shoulder to shoulder, the red body beside the blue one, not through it.

The two pictures are the same game seed before and after, at the same kind of moment. The play is not the same one, because the change alters the games, so it is the gap between the bodies that is the comparison.

The picture a shared link shows

The first picture someone sees when they share a link to the site is a still of the replay. It used to be a shooter releasing the ball with a defender's arm crossing the shooter's body. It is now a shot released with the defender right beside the shooter and clear space between their bodies, picked by the same footprint test over the game's shot releases, then checked from the side.

A 3-D basketball court seen from the side: a blue shooter with both arms raised, releasing the ball, and a red defender beside the shooter with an arm up toward it, clear space between their bodies, another red player standing to the left.
The share image now: a shot released with the defender beside the shooter, and room between the two.

From a circle to a footprint

Each body now has a footprint on the floor: an ellipse as wide as the player's shoulders and as deep as their chest, turned to face the way the player faces on screen (toward the ball, and the player holding the ball toward the hoop). Two bodies are far enough apart when their footprints do not touch, whichever way each one faces. Face to face that is one chest depth, side by side it is one shoulder breadth. The engine takes both sizes from the player's body, and the rule that places players, sends them to a rebound or lets a driver go past a defender reads the same footprints, so the picture and the play agree.

The trick that keeps this cheap is to stretch the floor, not to test ellipses. Around a body facing ahead, a step is measured in depths along the heading and breadths across it:

def delta(self, dx, dy):
    # along the heading over a depth, across it over a breadth
    return ((dx * ahead[0] + dy * ahead[1]) / depth,
            (-dx * ahead[1] + dy * ahead[0]) / breadth)

In those units the footprint is a plain unit circle, so every circle rule the game already had works unchanged, for any heading. It uses no trigonometry either, only a unit vector, so a game replays the same bits on every machine.

What it changed, measured

We count, in clips of the moments a replay is about (a rebound secured, a strip, a block, from a second and a half before to a second after), how many have two opposing players whose footprints meet at any instant. The same 24 simulated games, before and after the footprint became the floor:

ClipFootprints meet, beforeFootprints meet, after
Rebound secured66.6%34.2%
Strip32.1%4.8%
Block39.1%18.1%

The rebound was still the largest, so the next step looked at who was crowding whom. When a ball is loose, one player wins it and another loses, and the loser used to stop on the nearest free spot of the old circle. Now the loser stands at the nearest place, ring by ring round the winner, where their footprint clears the winner's. On three games that took the rebound clips with two bodies meeting from 81 of 213 to 34 of 218.

What is left

It is not zero, and it should not be. Where five bodies fight for one ball under a basket, some contact is the game. What remains is mostly that crash and scramble, and the next measurements split it by who was in the pile. The number to watch is how it falls as each cause is named, never a target set in advance: nothing was tuned to hit a figure, only the rule that keeps bodies apart changed, and the counts came out.

Open a replay, put the camera beside a rebound, and look at the gap between the shoulders.