# New Discoveries in the Theory of Battle Mechanics

## New Discoveries in the Theory of Battle Mechanics

A few months ago it came to the attention of GamePress that there were problems in the theory of how battles work in Pokemon GO. In battle simulations, raid bosses were using way too many charge moves compared to real life tests, and nobody knew why. Something was wrong and what it was needed to be found so that the tier lists, which come from simulations, are actually reliable!

In the past few weeks we have done extensive testing on different hypotheses to figure out what was wrong with the theory of battle mechanics. We were successful in finding the cause of the problem, and it has significantly improved our simulator results. For example, the time it takes for a Blissey to faint against Raikou on our private simulator went from 55 seconds to 70 seconds... which now agrees with our real-life tests to within 1 second. We plan to release the improved simulator soon (TM).

## The Results

The problem turned out to be a combination of two effects:

1. Raid bosses actually decide which move to use at the beginning of their previous move. This means that there is a whole ~3 seconds of energy gains in between moves that they cannot make use of for their next move! However, if the previous move was a fast move they still have the energy gain from that available to them for their next move.
2. After using a charge move, there is a delay before energy is used up. We have narrowed that delay down precisely to a particular variable from the GAME_MASTER file called "damageWindowStartMs". This delay is important because the boss often has a full bar of energy, so before the energy is used up all energy gains from taking damage are wasted!
3. Update: We have checked and confirmed that energy is also lost at damageWindowStart for players.

We also checked two other hypotheses which could have caused the problems we saw. They turned out to agree with the previous findings in battle mechanics and were not the source of the problem. So, to be clear, the following points are still true:

1. If a raid boss has enough energy to use its charge move, it will "flip a coin" and use the charge move 50% of the time.
2. When a raid boss takes damage, it gains energy equal to $$ceil(damage/2)$$ where "ceil", short for "ceiling", just means to round up.

## Methodology

We had four questions to test, and the order mattered because it was impossible to test some without knowing the answer to others. Any of the four questions, or a combination of them, could account for how few charge moves bosses were doing in reality. The questions were...

1. Do raid bosses use charge moves with 50% probability (when they have the energy)?
2. Do raid bosses gain energy equal to ceil(damage/2) when they are hit?
3. When do raid bosses decide on their next move?
4. When do raid bosses lose energy after using a charge move?

Question 1 methodology: In order to assess this without knowing the answer to question 2, we took many videos of being attacked by a raid boss (alone), letting it gain energy only by using fast moves, and then counted how many fast moves were used before the first charge move in the video. After a certain number of fast moves were used, the boss had enough energy, and sometimes it used a charge move on the first opportunity, sometimes on the 2nd, 3rd, etc. This was repeated many times: in the end, out of 311 opportunities, the boss used its charge move 151 times, or 48.55% with an uncertainty of 3.9%. In order to cause the discrepancies seen in videos the boss would have had to use the charge moves 30% of the time. That hypothesis was clearly not the problem! This was tested for a variety of raid bosses with charge move energy costs of 33, 50, and 100.

Question 2 methodology: The trick here was to "inject" some damage (and therefore some energy) to the boss before it makes a decision on whether to use a charge move next, and then see whether that energy allowed the boss to use a charge move early. This possibility could only account for the problems if the boss gained less than half of its damage as energy. For this test we showed that it must gain at least half of its damage as energy: While attacking a Raikou with Rhydon, we gave it just enough energy to use a charge move by damaging it (under the damage/2 hypothesis). It was then able to use a charge move on the next opportunity! So bosses must gain at least damage/2 in energy.

Question 3 methodology: To find out when a raid boss decides its next move:

Lower bound: We were able to get a video of Machamp giving Chansey just enough energy to use a charge move a moment before the beginning of its previous move. It was then able to use a charge move after, so the decision must be made no earlier than the beginning of its previous move.

Upper bound: In 22 trials, we "injected" a Dazzling Gleam (DG) Chansey with enough energy to use DG on the following move. Each time, the energy was injected between the beginning of its previous move and when its previous move deals damage (which is called damageWindowStart in the game master). The Chansey never was able to follow up with another DG... so it must have already made the decision of what to use next by the time it starts its previous move!

Question 4 Methodology: When is energy subtracted after using a charge move for raid bosses?

Lower Bound: To answer this one, we hit a Chansey with enough energy to use another Hyper Beam (HB) in the interval between the beginning of its previous move and damageWindowStart of its previous move. Despite this, the Chansey used Pound many times before using HB again, suggesting that the energy from the first HB had not been subtracted by the time we hit the Chansey! We repeated this a few times so that there was only a 1/256 chance of Chansey wasting all of those opportunities for a charge move by a coincidence.

Upper Bound: We tried the same thing but hit the defender just after damageWindowStart. Now it was able to use a charge move with the energy we injected. Therefore energy is lost at (or at least very close to) damageWindowStart.

Update: We have now checked that energy is also used up at damageWindowStart for players, too. This was done in a hyper beam Blissey vs Blissey matchup, where the enemy Blissey hurt our Blissey with HB just before damageWindowStart. We waited for some time, and the energy we would have gained from taking damage never appeared. That means our energy bar had already been full when we were hit, according to the numbers on the server side (which determine the actual outcomes). So energy is lost at damageWindowStart or later. It seems to be the same mechanic that the raid bosses experience.

As you can tell, some of these tests were done against gyms rather than raid bosses. The first test was done against both, the second against raid bosses, and the 3rd 4th tests were done against a mixture of both. Differences between the raid boss AI and the gym defender AI have not been found thus far.

## Credits

~The research was done by bioweapon and doublefelix921. bioweapon is a newcomer to the GamePress team (welcome!). DerMark76 contributed to the discussion and provided samples for question #1, as did polkadotjam and EpiCrimson.