The claw that pointed at the sky: a Crab Grab bug story
In Crab Grab, a crab boss sits on a rock at the top of the screen with a claw on a rope. The claw swings back and forth like a pendulum. You tap once to drop it, and it shoots out in whatever direction it is pointing, grabs the first thing it touches and reels it back in. Pearls, gems, treasure chests and trapped sea friends are worth points. Spiky urchins cost you time.
One early build of Crab Grab had no treasure at all. The reef was empty, the claw swung somewhere you could not see, and the score sat at 0 forever. This is the story of that bug, why it happened, and how we caught it. It comes down to one odd fact about computer screens.
On a screen, down is up
In school maths, you draw graphs with the Y number going up as you move up the page. Zero is at the bottom, and bigger numbers are higher.
Computer screens do it the other way round. They count Y down from the top, the same way you read a page: the first line is at the top, and each new line is further down. In our games, the top edge of the play area is Y = 0, and the bottom edge is Y = 720. So a bigger Y number means lower on the screen, not higher.
That flips angles too. An angle here is measured starting from "pointing right", the way you learn it at school. On a school graph, turning a quarter-turn the positive way (+90°) points straight up. On a screen, because Y is upside down, +90° points straight down. To point up on a screen, you use −90°.
None of that is a mistake. It is just how screens work, and every game programmer learns it. The trouble starts when you forget which way a particular thing in your game is supposed to point.
Two games, two directions
Our game Bubble Blast has a shell cannon at the bottom of the screen that fires bubbles up at a ceiling of sea friends. Its aim starts at −90°, straight up on screen. You can swing it left and right, but never closer than about 16° to flat, so you can't fire sideways along the floor.
Crab Grab is the opposite. The crab sits at the top and the claw hangs down into the reef below. Its resting direction should be +90°, straight down on screen.
Both games have one thing that aims and swings. Both fire it out in a straight line. They look so alike that it felt natural to build Crab Grab's claw on the same idea as Bubble Blast's cannon. That is where it went wrong.
The bug: a claw aimed at the sky
The early Crab Grab build reused the cannon's way of describing angles. So the claw was centred on "up" instead of "down". It swung happily back and forth, but above the crab, off the top of the screen where nobody could see it.
That alone would have been an obvious problem. The sneaky part was the treasure. Crab Grab places treasure in a smart way. To make sure every item can be reached, it picks a random direction inside the claw's swing and a random distance along it, then puts the item there. If the spot is off the edge of the screen, or too close to something already placed, it throws that spot away and tries again, up to 200 times for each item.
With the claw aimed at the sky, every random spot the game picked was above the top of the screen. Every single one was thrown away, so the game placed nothing. The reef was empty. There was nothing to grab, so the score stayed at 0.
And here is the important part: nothing crashed. There was no error message and no frozen screen. The crab sat on his rock, the reef background looked lovely, the timer counted down. A quiet bug like this is the worst kind, because the game looks like it is working.
How we caught it
We did not catch it by looking at the game. A screenshot of that build looked fine at a glance: a colourful reef, a crab, a score panel, a timer. If you were flicking through pictures, you might not notice anything was missing.
We caught it because the test checked the game's actual data. Data is the information a game keeps in its memory while it runs: where things are, what they are worth, how much time is left. Crab Grab keeps a list of every item in the reef. The test opened that list and counted what was in it. The answer was zero.
An empty list does not look pretty or ugly. It is just wrong, and a test that reads it cannot be fooled by nice background art.
The fix: swing around straight down
Now the claw swings around straight down, the way a claw on a rope should. It swings 1.02 radians either side of straight down. A radian is just another unit for measuring angles; a full circle is about 6.28 of them. So 1.02 radians is about 58°, which gives the claw a wide fan of nearly 117° across the reef. One full swing, from one side to the other and back again, takes about four and a half seconds.
Treasure is placed using that same downward fan, kept a touch narrower than the swing itself, and at distances the claw's rope can reach. So every item the game places is somewhere you can actually grab. Each wave fills the reef with 12 things: 4 pearls, 2 gems, 1 chest, 2 trapped sea friends, 2 urchins and 1 old boot. When three or fewer are left, a fresh wave arrives with a "MORE TREASURE!" banner.
The lesson: check the data, not the screenshot
Screenshots are great at showing you how something looks. They are bad at telling you whether it works. A game can look perfect and be completely broken underneath, and a game can look rough and play brilliantly.
The same idea saved us in a different way in Reef Hop, where a test robot showed us a fairness problem our own play could not. You can read about that in how we made Reef Hop fair.
What this means when you play
Next time you play Crab Grab, a few things follow from how the claw now works:
- Everything on screen is reachable. If you can see it, there is a moment in the swing when the claw points right at it.
- Heavy things reel in slowly. A chest is worth 150 but drags its way back up. An old boot is just as heavy and only worth 5, so try not to snag it.
- Sea friends are worth the most. Rescuing one scores 200 and adds 2 seconds to your clock: "RESCUED!"
- Urchins cost 4 seconds. The claw comes back empty, so time your tap for when the urchin is not in the way.
The claw used to point at the sky. Now it points at the treasure, and the score finally goes up.