Game hacking - Number theory

In most games there is a fair amount of mathematics involved. It may not always seem that way, but the numbers are there, you just have to find them. Now you don't have to be a mathematics expert to take advantage of numbers theory to cheat or win at games. Quite often you only need a single advantage to take you to the winning side. Although some of this will be applicable to board games, or MMORPS I am basing this article around browser based games. To illustrate I will use a fictional rpg game where I play an angry axe wielding barbarian. Lets call it browsercraft...

Negative numbers

Using negative numbers is the easiest way to gain an advantage in a game. It is based on the idea that subtracting a negative number from the product will add the subtraction to the product. Case in point: 2 - -2 = 4. The easiest way to abuse this in a game is to use a buy/sell screen. Most games have a buy/sell feature, although not all are susceptible to negative numbers.

In my fictional game I started out as you do in most games with little money or equipment. My 100 starting coins could only buy me a single healing potion. How boring is that? Luckily the game developers aren't familiar with negative numbers so the first thing I did was buy -1000 potions at 100 coins each. BAM! now I have 100100 coins (100 -(-1000*100)). Enough to buy all the top gear right off the bat.

Decimal points

The abuse of decimals is based around the fact that most games deal in complete numbers (integers) and most calculations performed result in decimal numbers (floating point). Sometimes you will be able to combine multiple decimals to tip the total over, other times you can use decimals to reap the rewards from the magic space between integers. I will give you a simple example:

Cash exchange
In "browsercraft" you can exchange gems for coins. However as you can only possess whole gems the calculation turns your number of gems sold into an integer (discarding decimal points) whilst the gems to coins conversion does not. So after an adventure my barbarian has 5 gems in his possession, each gem can be exchanged for 100 coins each. However, my barbarian will be using decimal points to extract more than the 500 coins it would normally exchange for. When asked how many gems to exchange I enter 0.9 as the amount of gems to exchange. This converts to 0.9 * 100 = 90 coins while subtracting 0 gems from my inventory (the .9 is discarded). Free cash!

There are also several other number techniques that are valuable when playing games. With or without being cheats. If there is enough interest I will write a follow up post where I cover techniques such as:
  • Overflows
  • Underruns
  • Reverse engineering formulas
  • Optimal paths


That was interesting, I'd like to see a follow-up post perhaps using some real examples from older games.


I have at least two follow up posts planned.

No Clean Feed - Stop Internet Censorship in Australia
Creative Commons License
This weblog is licensed under a Creative Commons License.