Alchemy Logo

Alchemy

For Nerds

My goal in creating Alchemy is to break from the structured tradition of most strategy games. In those games, you select from a limited choice of units, you are driven through a narrative in some way, and a lot of attention is paid to making the game look as realistic as possible. Alchemy is designed to give the player the ability to do whatever they want, but with concrete goals to accomplish on their own timeframe, with graphics that are designed to communicate information, not look realistic.

Combat

This goal, let's be honest, is incredibly nerdy. If you think Alchemy looks like a cool game, then you are probably quite nerdy as well. And if there's one thing nerds like us love, it's DATA. So here's a ton of it. By no means is this an exhaustive list of all the information used in Alchemy - for that you can just look at the source code. Instead, provided here is an explanation of my reasoning for the features in the game, future plans for Alchemy, and GRAPHS!

Calculating Golem Stats

If you've read the features page, you'll know that Alchemy has 7 resources, all of which add something different to the unit as a whole. For instance, a golem made with 5 grass will have low health and attack, but heal very rapidly. Adding a little stone to that golem will increase health and attack, but the unit will heal back to full health slower.

But exactly how much health and attack will be added to the golem? WHERE IS THE MATH? And how is speed calculated? This chart shows how much each individual resource contributes to the golem's base stats.

Resource Health Attack Speed Bonuses
Grass 2 0.1 3 Healing + 0.5
Dirt 3 0.4 3 none
Stone 5 0.6 2 none
Iron 8 0.8 2 none
Titanium 8 1.0 5 none
Lead 15 0.6 1 none
Uranium 6 0.1 2 Radiation + 0.75

The following is an explanation behind each of the algorithms used to calculate a golem's base stats. To see the algorithms lined up in handy mathematical notation, see the chart at the bottom of this section.

Calculating the golem's base health is quite simple. Simply add up the health of the resources used in the golem. So if a golem was made with 2 grass, 2 dirt, and 2 stone it would have (2*2) + (2*3) + (2*5) = 20 base HP. When it comes to health, the more resources the better. Lead in particular is an excellent investment.

Attack is a little more complicated. I realized that simply adding the attack like I did with HP would result in golems with hugely varying attack, ruining the fun of the game. So I made each additional resource contribute less and less to the total attack of the golem. To do this, I added up all the attack from each resource and raised it to the 2/3 power, followed by multiplying the result by 4.5 and rounding to the nearest whole number. I picked these numbers because of it gave a small bonus to the attack of weaker golems, without unfairly penalizing the larger golems. This allows weaker nations to actually compete with someone with a lot more resources, rather than being simply decimated.

This graph compares the modified attack (blue) to if the attack simply grew linearly (green) of an example resource, in this case, titanium. The maximum unmodified attack in this game is 99, from a golem made from 99 titanium. This attack gets penalized to about 96, which isn't much. Meanwhile weaker golems are bumped substantially above where they would be if attack grew linearly.

Modified vs Linear

Speed is a little more complicated. I wanted to accomplish several things with speed. 1) Golems with more resources should move slower because they are "heavier." 2) Golems shouldn't move so slow that they overly infuriate the player. 3)Speed should incorporate into mining, but not so much that it destroys any benefits given by high attack, as golems with high attack tend to be heavier and therefore slower. (Mining speed is determined by a combination of attack and speed, explained a little later).

The unmodified speed is calculated by averaging the speeds of the resources used in the golem. For example, if 3 grass and 3 titanium were used in a golem, the unmodified speed would average out to 4, as grass has a base of 3 speed and titanium 5 speed. Then, for every resource used in the golem there is a .02 penalty to speed. So this golem would take a .12 penalty for its 6 resources, leaving it with 3.88 speed.

However, this number "3.88" is kind of meaningless. In the game I translate speed into the delay between moves the golem makes. So I raise this number to the -1 power, inverting it. This number becomes the number of seconds between the moves the golem makes. In this golem's case, there is a .258 second delay between its moves. The golem ended up taking a .008 second penalty for its "heaviness". This is a tiny penalty, but for larger golems it can be quite significant. For this reason, golems are not allowed to go slower than a 3.3 second delay between moves. 3.3 seconds is quite slow, so I arbitrarily decided this would be the lower limit of golem speed.

Fastest Possible Golem 5 Titanium 0.204 second delay
Slowest Possible Golem 99 Lead 50 sec delay (w/out lower limit)

50 seconds is pretty excessive in terms of slowness, and ends up making these golems essentially useless. Thus, the lower limit.

When attacking other golems, each one damages the other precisely every 0.5 seconds, regardless of speed. This is to prevent fast golems from getting an overwhelming advantage in battle. However, when it comes to mining, speed does play a role. When a golem mines a block, it deals its attack's worth of damage to the block. Grass and dirt blocks have 100hp, stone and iron 200hp, titanium lead and uranium 300hp. When the block runs out of health, the nation that mined it is awarded some of that resource. Each golem deals damage to the block it is mining 2x as quickly as it moves. This allows even the weakest golems the ability to mine dirt or grass blocks in a timely manner. It also gives titanium a huge advantage in mining, as titanium is high in attack and speed.

Healing ability adds up linearly, like base HP. For every grass in the golem, it recovers 0.5 health every 0.5 seconds, providing the golem hasn't taken damage in the past 2.5 seconds.

Radiation damage is calculated similarly to attack. Unmodified radiation damage is raised to the 2/3 power and rounded to the nearest whole number. Radiation damage affects all enemy golems within a 5 block radius. The golem being attacked will receive Radiation-Damage/Distance-to-Enemy2 damage. This means that if the golem is 5 blocks away, the golem will take 1/25 the base radiation damage. But, if the victim golem is right next to the irradiating golem, it will receive radiation damage at no distance penalty. This makes Uranium golems effective in fighting multiple surrounding enemies. Like regular attack, radiation damage is applied every 0.5 seconds.

This chart summarizes all of the math used to calculate golem stats. In the algorithms, let r represent a particular stat of one resources used in the golem. So, under "Health," Σr simply means to add up all the health of the resources used in the golem; under "Attack," Σr would mean to add up all the attack of the resources used in the golem. Let T represent the total number of resources used in the golem. If 8 resources total were used in a golem, T=8.

Golem Base Stat Algorithm
Health \(\sum r\)
Attack \(\sum r^\frac{2}{3}\times4.5\)
Speed (general)* \(\frac{1}{\sum r - (.02 \times T)}\)
Speed (mining)* \(\frac{1}{2 \times (\sum r - (.02 \times T))}\)
Healing \(\sum r\)
Radiation Damage** \(\sum r^\frac{2}{3}\)

* Speed represents the delay in seconds between a golem's moves. If Speed > 3.3 seconds, it is set to 3.3 seconds.

** Radiation damage depletes with distance, specifically at a rate of (let R = base radiation damage, and D = distance to an enemy golem) R/D2.

Future Development Plans

These are some ideas I have to implement in further versions of Alchemy. Feel free to submit your own suggestions!