Powder Game codes are used in Powder Game to save what's on-screen as a code. These codes can be then saved in a file or otherwise stored for later use. To get a code, press the "Get" button. To load a code, paste a code into the box and press "Set."
Data Structure (Powder Game)
A Powder Game Get-Set code is comprised of an 8-character header optionally followed by an 8-character extension, followed by a sequence of compressed element and object data, and a 3-character checksum at the end.
All data in both games' codes, except where otherwise noted, is encoded in a base 64 numeral system, where each character is a digit representing a value from 0 to 63. The digits, in order, are
*. Any other characters will be read as zeroes.
The code's header contains global values such as the BG and Speed settings. Unlike most other parts of the code, these values are not stored as base 64, but instead follow ASCII order starting at
'0'. This is only noticeable with the BG value however, as the order of digits after
'9' starts with
';' before progressing into capital letters.
Attempting to load a code with any values for header digits other than the ones listed will crash the game.
The structure is as follows:
|0||Code type||If this is anything other than zero, this code contains the 8-character header extension. Used for backwards compatibility with codes from earlier versions that did not use the extension.|
|2||BG||The BG setting (see below)|
|3||Dot||The dot limit setting (0 is DOT S, 1 is DOT M, 2 is DOT L)|
|4||Grid||The grid setting (0 to 7)|
|5||Speed||The speed setting (0 is x1, 2 is x2, 3 is x4, 4 is x8)|
|6||Side||The side setting (0 is SIDE-OFF, 1 is SIDE-LOOP)|
The BG values are as follows:
|8||Mouseclicks||The amount of times the player has clicked on the game canvas, in reverse digit order. Used for quality control of uploads; if this number is less than 50, the game will reject upload attempts and display the message "Please carefully created." Defaults to 50 when loading a code without the extension.|
Element and object data
It uses a simple dictionary-based compression algorithm with repetition compression as well, and consists of a sequence of 3-character-long units. Each unit consists of a 2-digit dictionary reference followed by one digit of literal data. A dictionary reference points to the location of another unit in the sequence, and is recursive, as that unit can in turn can point to another unit with its own dictionary reference, and so on. Dictionary references start at
01; a dictionary reference of
00 is null and is ignored.
To decompress screen data, each unit must be evaluated in sequence. For each unit, its dictionary reference must be evaluated recursively until a null reference is found which ends the reference chain, and then the literal values of every unit in the chain are added to the end of the decompressed output in reverse order. If a literal value x greater than 47 (
l) is encountered, it signifies that the literal value directly before it should be repeated
x - 48 times. However, if another literal value y also greater than 47 is encountered directly after x, it signifies that x and y together are a reverse-order two-digit number with the value of
((y - 47) * 16) + (x - 47) - 1 and that the value immediately before x should be repeated that many times instead.
The result is a sequence of at least 120000 digits (at least one for each pixel in the game field), each of which specifies an element, an object, an attribute, or empty space. Elements or objects such as Fireworks or Players are followed by a second digit specifying their attribute. Some elements such as Clone might seem to have an attribute while the game is running but do not actually save it; these do not show up in the code.
Attempting to load a code with any non-base-64 element digits will simply result in those values being read as empty space. However, the two remaining empty spaces for elements,
l, will crash the game when loaded. Additionally, attempting to load a code with more than 2 Players hacked in will also crash the game.
The values corresponding to each element and object are as follows:
|8||8||Fan||Yes (wind direction)|
|M||22||Box / Create||Yes (size; becomes Create if size value is 10)|
|U||30||Player (no element)||No|
The checksum is an encoded 3-digit number at the end of the code that is intended to prevent any corruption or tampering to the code. It is stored as a hexadecimal number in reverse digit order and does not use base 64 encoding. The first digit is a lowercase letter (
a-p), the second is an uppercase letter (
A-P), and the third is a numeric digit (
0-7). Encoded this way, for instance, the checksum
0x507 would become
hA5. The maximum value for the checksum is
The checksum can be computed by first adding together the ASCII value of each character in the code multiplied by its position in the code modulo 255. (The position is 1-based, so the first character would be multiplied by 1, the second by 2, etc.) The checksum is then obtained by computing that value modulo
The Get-Set mechanism will reject any code where the computed checksum does not match the checksum value stored in the code.
- Get-Set, the article about the Get-Set mechanism in general.