Still Going (Daily COVID-19 data update CCCXXIII)

Graphs day 323, pandemic day 330, day 401 since the first cases were diagnosed.

Total cases of COVID-19 diagnosed worldwide: 103,412,282

Total deaths: 2,232,405

Just a very quick update today while I look into some other trends in more detail. Usual graph formats, click for a larger version of each.

Countries that have consistently gotten it right

Countries where COVID-19 was stayed mostly contained throughout the pandemic

Countries where COVID-19 is currently under control(-ish)

Countries where COVID-19 was bad but are now sort of under-control-ish

Countries moving in the right direction(-ish)

Regions where cases are still high but are currently stable

Countries where the pandemic is still awful

Regions where the epidemic is still raging

Fortunately, even in these countries, cases are beginning to decrease; although in the meantime, Spain has moved ahead of the U.S. into first place on this graph in terms of cases per day.


Sadly, Corona Data Scraper has stopped reporting data in the way I was using it, so I have gone back to using the data from the JHU Coronavirus Resource Center. You can download the data from their GitHub repository. You are welcome to use my Excel spreadsheet (version 9.2).

Bug Parade: When Gandhis Attack

Sometimes we can learn a great deal about how to do things right from the times when things went wrong. Welcome to a new occasional series: The Bug Parade!

Screenshot from Civilizaiton 1: Mahatma Gandhi, leader of the Indians, says "Very well, we will mobilize our armies for WAR! You will pay for your foolish pride!"
Gandhi attacks

The Civilization series is one of the most enduringly successful computer strategy games of all time. The games let you control a human civilization, starting in 4000 B.C. and guiding them into the 21st century. You control all aspects of your civilization, from military expansion to scientific advancement to keeping your citizens happy. Along the way, you encounter other civilizations and their leaders. You can go to war with these civilizations, make peace, manage alliances, and negotiate with their leaders. The series is one of the most incredibly addictive, just-one-more-turn strategy games ever created.

It all started in 1991 with the original game of that name, now informally known as Civ 1, created by legendary game designer Sid Meier. Nearly 30 years later, the original game still has a devoted fanbase, who not only still play the game but also dig deep into the game’s code to create fan mods to play and share.

Creating a game that people still enjoy after 30 years is an amazing achievement on its own, but it becomes absolutely mind-blowing when you realize that the entire game takes up just 2.6 megabytes of space, less than a single song stored in MP3 format.

Size comparison: the entire game (2.4 Megabytes) against a single MP3 (3.4 Megabytes)

Creating such a complex game in such a tiny amount of storage space necessarily meant that many compromises had to be made – and from one of these compromises came one of the most famous software bugs in history.

In 1991, the Internet had yet to penetrate into public consciousness, and so the idea of playing a game online was still new. Meier knew this, and knew that Civilization presented enough of a design and programming challenge already, so he decided to keep it firmly a one-player strategy game. And that meant that the quality of the game would depend on the quality of the player’s computer-controlled artificial intelligence (AI) opponents. If the AI opponents made good decisions, the single human player could respond to the challenges presented with decisions of their own.

But that was the challenge – how could the game developers make convincing AI for opposing world leaders while making the entire game fit into an absurdly low 2.6 megabytes? All opposing leader decisions where based on a set of simple formulas. Will Hammurabi offer a peace treaty? Check the formula. Will Mao Tse Tung launch a nuclear weapon? Check the formula. And to account for differences between leaders, the input to the formula was a simple scale from 1 to 5, ranging from most peaceful to most warlike: Mahatma Gandhi scored 1, Genghis Khan scored 5.

But there was another game design point to consider. One of the things that made Civilization so groundbreaking was that it had multiple ways to win. You can win by conquering the entire world, by winning the space race, or by having the highest score when the game ends in 2100 AD. To reward the player for sticking around for the modern era, – as well as to reflect historical experience – opponents become less aggressive. Specifically, each leader’s aggression rating drops by two.

But if aggression drops by two, what happens to Gandhi, who already had an aggression rating of one? Logically, his aggression rating should drop to -1, making him even more peaceful than he was already. But if logic prevailed, we wouldn’t be talking about this in a recurring series called The Bug Parade.

Remember that with only 2.6 megabytes to work with, programmers were desperate to save space, so they used every strategy they could think of to make their code use memory efficiently. Since they knew the aggression rating went from 1 to 5, they used only one byte of memory to store the value. One byte of memory can store values from 0 (in binary, 00000000) to 255 (in binary, 11111111). You can probably already see the problem with this.

If the program could only store values from zero to 255, and it had to calculate 2-1, what was it supposed to do? The only thing that made any sense at all was for the odometer to turn over, for the calculation to wrap around, and to return the result 255.

Subtracting 1 from 00000000 (equal to zero) gives 11111111 (equal to 255)
Illustration of an integer underflow error

Thus, as soon as the player discovers Democracy, Gandhi’s aggression jumps to 255.

Out of five.

And so as soon as Gandhi gains the ability to launch nuclear missiles, he immediately launches them at everyone on the next turn, and on every turn after that until he is dead or everyone else is dead.

The bug was never caught in testing, but of course as soon as the game shipped, millions of players discovered it, and it became legend. The bug was quickly fixed in the sequel, but by that point “Nuclear Gandhi” had become enshrined in popular culture.

Memes weren’t really a thing in 1991, but “Nuclear Gandhi” was an inside joke among computer gaming fans for literally decades. And as soon as memes became a thing, Nuclear Gandhi memes became a thing too. Here’s a mashup of Nuclear Gandhi with another famous meme, Der Untergang subtitles:

Coding the game in such a way as to allow a variable underflow error wasn’t even really a mistake, just a design decision that had consequences that were unexpected – and hilarious.

But that’s the nature of the parade – the bugs show up when you least expect them.

I hope you enjoyed this light-hearted introduction to where software bugs come from and what they can do – because when the Bug Parade returns, the next one will be pure nightmare fuel.