Qraft

How QR code masks, error correction and versions show up in game creatures

The same content makes the same QR code

The QR code standard fixes how the characters of the content are turned into code and in what order. With the same settings, the same content always produces the same pattern of black and white.

In Qraft's game where QR codes hatch creatures, the same content hatches the same creature on any device. Its looks and moves depend only on the content, while its stats vary a little with how it was read (camera, image or text) and the week it hatched. Some of a creature's traits come from properties of the QR code for that content.

Mask: eight patterns that even out black and white

Content turned straight into code can leave clumps of black, or shapes that look like the position markers, and readers can get confused. So one of eight fixed patterns is laid over the code to flip black and white. This is the mask.

The encoder tries all eight and picks the one with the least bias. The chosen number is written into the format information inside the code, and readers use it to remove the pattern before reading the content. In the game, the mask number plays a part in deciding a creature's element. Changing a single character can change the chosen mask, so even similar URLs can hatch creatures of different elements.

Error correction: extra code that keeps it readable

Besides the content, a QR code carries error correction code. If part of it gets dirty or torn, the rest of the code lets the original content be recovered by calculation. There are four levels, L, M, Q and H, which can recover about 7 %, 15 %, 25 % and 30 % of the data.

Higher levels add more extra code, so the same content needs a larger QR code. To compare every content under the same conditions, the game uses one fixed error correction level when it works out the properties. Whether the QR code you scan was made with H or L, the same content hatches the same creature.

Version: the number of modules, and a creature's HP

The version tells how many modules a QR code has, from 1 to 40. Version 1 is 21 × 21 modules, each step up adds 4 modules on each side, and version 40 is 177 × 177. Longer content needs a larger version.

In the game, creatures hatched from content with a larger version get slightly more HP. It is a small bonus for content that takes more effort, such as long URLs or contact cards. Capacity by version is covered in the article on version differences.

Content type: URL, Wi-Fi, contact, payment, text

The QR code standard itself does not tell a URL from a business card. Readers tell the type from how the content is written. A Wi-Fi QR code starts with "WIFI:", and a contact is written in the vCard or MECARD format (article on Wi-Fi QR codes).

The game sorts content into five types, URL, Wi-Fi, contact, payment and text, and gives each type a different special move. Collection cards show the version and the content type, so scanning and comparing the QR codes around you shows which property is at work.