Skip to content

Instantly share code, notes, and snippets.

@Lusamine
Created February 16, 2026 05:06
Show Gist options
  • Select an option

  • Save Lusamine/1bf62b88ff63d705b22394a20f87ddca to your computer and use it in GitHub Desktop.

Select an option

Save Lusamine/1bf62b88ff63d705b22394a20f87ddca to your computer and use it in GitHub Desktop.
A technical explanation of how donuts are generated in Legends: Z-A

Introduction

In the Legends: Z-A DLC, donuts are used to enter hyperspace zones. They can each have up to 3 bonuses, which are categorized into 5 flavors. The user can control which berries are added to a donut recipe, but the results are randomized.

This is a technical description of how LZA creates donuts from berries. I will first go over the algorithm and then finish with some examples to illustrate.

Donut Generation Algorithm

1. Convert the flavor values to a budget to spend on Flavor Powers.

First, the game will go through each of the flavors and decide how many points it earns to roll Flavor Powers later on. The order is Sweet -> Spicy -> Sour -> Bitter -> Fresh, although this does not have much relevance as far as I can tell.

Points are assigned based on specific thresholds and are tracked for each flavor. For example, a donut with a flavor value of 760 will be assigned 9 points for that flavor, and a donut with a flavor value of 500 will be assigned 6 points for that flavor. A flavor must have a value of 120 or higher to be eligible for a Flavor Power.

Flavor Threshold Level Budget
120 1 point
160 2 points
200 3 points
300 4 points
360 5 points
420 6 points
525 7 points
700 8 points
760 9 points

What about Rainbow Donuts?

Rainbow donuts occur when the top two flavors have identical values. If the donut is Rainbow, then every flavor gets 1 additional point, up to a maximum of 9. A Rainbow donut with a Sweet flavor value of 420 would actually earn 7 points towards Sweet Flavor Powers.


2. Roll for the levels of Flavor Powers.

Before we go on, it is important to understand that each Flavor Power has a cost. The cost is generally the same as the level of the Flavor Power, but there is one exception: all Sparkling Powers cost 3 points, regardless of level!

Flavor Powers Cost
All Lv. 3 Flavor Powers
and Lv. 1-3 Sparkling Powers
3 points
All Lv. 2 Flavor Powers
except for Lv. 2 Sparkling Powers
2 points
All Lv. 1 Flavor Powers
except for Lv. 1 Sparkling Powers
1 point

For each flavor, the game will now roll to decide if the donut gets a Flavor Power that costs 1, 2, or 3 points. Once a level of Flavor Power is decided, those points are deducted from the budget, and rolling continues with the chance for the budget remaining.

The specific power is not decided at this step; only a list of costs is determined for each flavor.

Level Budget Cost 1 Power Chance (%) Cost 2 Power Chance (%) Cost 3 Power Chance (%)
1 100
2 100
3 50 50
4 25 75
5 19.05 42.86 38.10
6 14.29 28.57 57.14
7 9.52 33.33 57.14
8 33.33 66.67
9 100
Example of how a flavor's budget is spent
  1. Let's say our donut starts with a budget of 9 in a flavor.
  2. According to the table, the first roll has 100% chance to be a cost 3 Flavor Power.
  3. Once a cost 3 power is selected, the 3 points are deducted from the budget.
  4. The next roll will be with a budget of 6 points, which has a 14.29% chance to be a cost 1 Flavor Power, 28.57% chance to be a cost 2 Flavor Power, and a 57.14% chance to be a cost 3 Flavor Power.
  5. Rolling continues until the budget is exhausted.

There is an off-by-one in the randomization for these costs, which adds 1 point to the highest available group in each row. This causes these unusual numbers and favors the player getting higher level powers.


3. Decide the total flavor budget of the donut.

Next, the game will determine the total flavor budget of the donut. All the flavor values are summed to give the Flavor Score, and this table is used to decide the total points the donut is permitted to have.

Total Flavor Threshold Total Level Budget
120 1 point
240 2 points
350 3 points
420 4 points
500 5 points
600 6 points
700 7 points
800 8 points
960 9 points
Example of how a donut's Flavor Score decides its total budget

This donut, for example, has a Flavor Score of 80 + 40 + 760 + 80 = 960, which gives it a budget of 9 points for all of its Flavor Powers.

However, it only has two Flavor Powers because only the Bitter flavor is strong enough, each flavor only has two categories, and only one Flavor Power from each category is permitted. This will be explained more in the next step. Example Bitter donut


4. Randomly pick Flavor Powers based on the highest levels rolled.

Finally, the game will use the list of costs for each flavor to assign Flavor Powers to the donut.

It will prioritize the highest cost that was rolled between all the flavors. If a lower cost power was rolled before a higher cost power, the higher cost is still selected. If more than one flavor has the same highest cost, then the flavor that has the highest flavor value is chosen.

If more than one flavor has the same highest cost and their flavor values are tied, the game will roll to break the tie. This can be a 2-way tie or a 3-way tie.

Once selected, that flavor and cost combination is removed from the pool for the next round.

Example of how the game selects the highest cost Flavor Powers

Suppose we previously rolled the following cost profile:

  • Spicy (300): cost 2, cost 1
  • Sour (210): cost 2, cost 1
  • Bitter (210): cost 2, cost 1

The highest cost is 2, but all 3 flavors are tied. Since Spicy has the highest flavor value, the game will first assign a Spicy Lv. 2 Flavor Power. Then, it will be removed from the pool:

  • Spicy (300): cost 1
  • Sour (210): cost 2, cost 1
  • Bitter (210): cost 2, cost 1

Now, the next highest cost is 2, and this is tied between Sour and Bitter. Since both have 210 points, the game will roll to break the tie between them. The next power has a 50% chance to be a Sour Lv. 2 Flavor Power and 50% chance to be a Bitter Lv. 2 Flavor Power.

After the second power is assigned, the third flavor power will be the remaining flavor as a Lv. 2 Flavor Power.

Once a flavor and cost are decided, the game picks which Flavor Power is assigned! The pool it selects from is a list of all eligible Flavor Powers that match the cost and flavor, and all the entries have an equal chance of being chosen. For example, if we are rolling for a Sweet Flavor Power that costs 3 points, the pool will include all 57 Sparkling Powers (remember, they are all cost of 3 regardless of level) and the three Lv. 3 size powers (Alpha, Humungo, Teensy).

Each flavor’s powers are separated into two categories, and the donut is limited to one power from each category. If a Sparkling Power was already chosen, and another Sweet Lv. 3 is being rolled, the game will pick between the three Lv. 3 size powers (Alpha, Humungo, Teensy) only.

Here, you can see the different Flavor Powers and how they are separated into two categories within each flavor.

Table of Flavor Powers

If the donut runs out of budget when assigning a Flavor Power, the Flavor Power is instead downgraded to the highest the remaining budget permits. For example, if only 2 points of donut budget are left, and a cost 3 Flavor Power is next to be assigned, this will simply be added as a Lv. 2 Power.

I am not aware of any donuts that can run out of budget on a Sparkling Power to know what would happen if say, only 2 budget points remain but a Sparkling Lv. 1 is selected. This situation is unusual because of how all the Sparkling Powers cost 3 points. If you can find a recipe, I can test it.

Special Donuts

There are five special donuts used to meet Darkrai, Kyogre, Groudon, Rayquaza, and Zeraora. These donuts have a few special rules.

If a special donut qualifies to be a Rainbow donut, it will still act like a Rainbow donut under the hood even though it is displaying as the special donut. That means every flavor gets +1 to its budget!

The first Flavor Power slot is automatically filled by the special one associated with that donut. This special power allows the donut to be used for the Legendary's portal.

Pokémon Special Flavor Power
Darkrai Pitch-Black Power
Groudon Ruby-Red Power
Kyogre Sapphire-Blue Power
Rayquaza Emerald-Green Power
Zeraora Thunderclap Power

The other two Flavor Powers are assigned based on the flavor values in the typical manner.

Special donuts exclude powers that would not be useful in the boss fights:

  • Sweet: all powers ineligible (no Sparkling Power or size powers). These bosses are shiny-locked and scale-locked to 128.
  • Spicy: all powers eligible (offensive bonuses)
  • Sour: only Mega Power Charging/Conservation (no Item Power or Big Haul). There are no floating Poké Balls.
  • Fresh: all powers ineligible (no Catching Power or Encounter Power). The bosses are guaranteed catch and encounter.
  • Bitter: all powers eligible (defensive bonuses)

Donut Naming

Donut names are made up of several parts: an adjective, a berry type, and an ingredient.

Example of a donut name

Adjective

The adjective is determined by the type of the first Flavor Power. The level does not matter, and the sub-type only matters for Item Power variants.

List of Donut Adjectives
Flavor Power Adjective
Alpha Power Imposing
Humungo Power Humungo
Teensy Power Teensy
Sparkling Power Sparkly
Move Power Movetastic
Attack Power Mighty
Sp. Atk Power Smart
Speed Power Quick
Item Power: Berries Bountiful
Item Power: Candies Candied
Item Power: Treasure Treasured
Item Power: Poké Balls Ballistic
Item Power: Special Remarkable
Item Power: Coins Gilt
Big Haul Power Lavish
Mega Power Charging Energizing
Mega Power Conservation Enduring
Resistance Power Protective
Defense Power Tough
Sp. Def Power Courageous
Catching Power Inescapable
Encounter Power Tempting

Berry Type

Each donut's name contains the name of a berry. We believe the way the donut’s berry type chosen is:

  1. Select the berry that has the highest quantity.
  2. If multiple berries are tied, pick the berry from the tied berries that has the highest total flavor points.
  3. If multiple berries are still tied, pick the berry from the tied berries that has the highest value of a top flavor (can be a tied flavor).
  4. If multiple berries are still tied, pick whichever berry from the tied berries was added first.

These rules were based on testing and observing; if you notice any discrepancies, please let us know!

Ingredient

The donut’s ingredient type is based on the dominant flavor. If multiple flavors have the same highest value, the donut will become rainbow.

Highest Flavor Ingredient
Sweet Meringue
Spicy Curry
Sour Jam
Bitter Chocolate
Fresh Cream
Multiple Tied Rainbow

Example Donuts

This section will go through how two common donut recipes generate based on this knowledge. I recommend starting with the Hyper Tanga Berry x8 recipe because it focuses on a single flavor and is easier to understand. Once it makes sense to you, you can see how the mechanics change with the Haban Rainbow recipe, which has two top flavors.

Hyper Tanga Berry x8

This familiar recipe is the best for both Sparkling Power and Alpha Power since it can reach the highest possible Sweet flavor value of 760. The combination of 8 Hyper Tanga Berries yields a donut with 80 Spicy, 760 Sweet, 80 Sour, and 40 Bitter.

Hyper Tanga Berry x8 Recipe

  1. The first step is to assign budget points to each flavor. Since only Sweet has over 120 points, it is the only flavor that has any points to be spent! None of the other flavors will be represented in the results. The game converts 760 Sweet points to 9 points to be spent on Sweet Flavor Powers.

    Flavor Threshold Level Budget
    760 9 points
  2. The next step is to roll for the levels of Flavor Powers. Since we start at a budget of 9, the first roll has a 100% chance to be a cost 3 Flavor Power.

    Level Budget Cost 1 Power Chance (%) Cost 2 Power Chance (%) Cost 3 Power Chance (%)
    9 100
  3. We spend 3 points for this cost 3 Flavor Power. The next roll will be from a budget of 6 with the following chances. We could potentially roll a cost 1, cost 2, or cost 3 Flavor Power.

    Level Budget Cost 1 Power Chance (%) Cost 2 Power Chance (%) Cost 3 Power Chance (%)
    6 14.29 28.57 57.14
  4. Let's suppose we roll a second cost 3 power. This brings our remaining budget down to 3. Our next roll has a 50% chance to be a cost 1 power and 50% chance to be a cost 2 power. The remaining rolls won't matter since we already rolled two cost 3 powers, and we are limited to only two Sweet Flavor Powers.

    Level Budget Cost 1 Power Chance (%) Cost 2 Power Chance (%) Cost 3 Power Chance (%)
    3 50 50
  5. Next, we'll decide on the total budget of the donut. This sets a limit on the combined costs of all Flavor Powers. The Flavor Score for this donut is 80 + 760 + 80 + 40 = 960, which hits the highest threshold and gives this donut 9 total budget points to spend. This is plenty to accomodate the two cost 3 Sweet Flavor Powers we are going to add.

    Total Flavor Threshold Total Level Budget
    960 9 points
  6. Now, we can finally decide the Flavor Powers. Recall that we rolled two cost 3 Flavor Powers, and then finished with some cost 1 and cost 2 Flavor Powers that won't matter for this example. Since only one flavor has any points, and cost 3 is the highest value, our first Flavor Power will be one that is worth 3 points.

  7. Which Sweet Flavor Powers are worth 3 points? Unfortunately, all of the Sparkling Powers are worth 3 points. There are 18 types (specific type and "all") and each type has Lv. 1, Lv. 2, and Lv.3. All 57 of these Sparkling Powers are added to the pool.

  8. The three Lv. 3 size powers are also worth 3 points! The game adds Alpha Power Lv. 3, Teensy Power Lv. 3, and Humungo Power Lv. 3 to the pool for a total of 60 possible options. All of these options have the same chance of being chosen.

  9. This is why this donut recipe tends to give Sparkling Power in the first slot; if any cost 3 power is rolled, the chance of the first slot being Sparkling Power is 57/60, and the chance of the first slot being a size power is 3/60. Let's assume we roll one of the Sparkling Powers, which could be any type and any level.

  10. The next highest Flavor Power we rolled was another cost 3 power. However, since we already randomly picked a Sparkling Power for the first slot, all of the Sparkling Powers are now excluded from the second slot. The pool for the second roll only has 3 entries: Alpha Power Lv. 3, Teensy Power Lv. 3, and Humungo Power Lv. 3. One of these is randomly chosen.

  11. The result might be something like the image below, where the first slot is a Sparkling Power (worth 3 points) and the second slot is a Lv. 3 size power (worth 3 points).

    Hyper Tanga Berry x8 Result: Sparkling + Size
  12. What if the first cost 3 power had selected one of the 3/60 size powers? Then you might get a result like this, where the first slot is a Lv. 3 size power, and the second slot is chosen from the 57 remaining Sparkling Powers.

    Hyper Tanga Berry x8 Result: Size + Sparkling
  13. Lastly, there is the rare case where only one Flavor Power is produced. How could this happen? This is a consequence of all the Sparkling Powers being worth 3 points. Suppose that we rolled a cost 3 power followed by a cost 2 power. Now, suppose the cost 3 power selects a 3/60 size power. When the donut tries to roll a second slot for the cost 2 power, no Flavor Powers are eligible; the other size powers are locked out by the size power in the first slot, and all the Sparkling Powers are worth 3 points! This yields a donut with a single size power.

    Hyper Tanga Berry x8 Result: Size only

Because of the high starting budget for Sweet, the Hyper Tanga Berry x8 recipe is great if you are trying to get both Alpha Power Lv. 3 and Sparkling Power. However, all of the Sparkling Powers being 3 points makes it quite difficult to get a Lv. 3 power. You should note that if your target is shiny alpha Pokémon, Alpha Power has a greater benefit than Sparkling Power does, so it is worth resetting less and spending more of your time on seeing more encounters with Alpha Power active.

Rainbow Haban

This popular recipe has been promoted because it results in combinations of Fresh and Sweet Flavor Powers, allowing for a donut that potentially has Sparkling Power, Alpha Power, and Catching Power. The combination of 6 Hyper Haban Berries, 1 Hyper Payapa Berry, and 1 Hyper Yache Berry yields a donut with 540 Sweet, 15 Sour, 25 Bitter, and 540 Fresh.

image

  1. The first step is to assign budget points to each flavor. Both Sweet and Fresh have over 120 points, so both flavors will earn points to be spent. The 540 flavor points convert to 7 points to be spent on Sweet and Fresh Flavor Powers.

    Flavor Threshold Level Budget
    525 7 points
  2. Since Sweet and Fresh are the strongest flavors and they are tied, this becomes a Rainbow donut! A Rainbow donut gives +1 point to every flavor. Our final budget for each flavor is:

    • Sweet: 8 points
    • Spicy: 1 point
    • Sour: 1 point
    • Bitter: 1 point
    • Fresh: 8 points
  3. The next step is to roll for the levels of Flavor Powers. Since every flavor has points, we will be rolling a lot of potential Flavor Powers. Both Sweet and Fresh will start rolling from the rates for a budget of 8 points, which gives us a 66.67% chance to be a cost 3 power and a 33.33 chance to be a cost 2 power. The other three flavors will only roll a cost 1 power. For this example, suppose both Sweet and Fresh roll a cost 3 power for their first power.

    Level Budget Cost 1 Power Chance (%) Cost 2 Power Chance (%) Cost 3 Power Chance (%)
    1 100
    8 33.33 66.67
  4. We spend 3 points for the cost 3 Flavor Powers. The next roll will be from a budget of 5 with the following chances. We could potentially roll a cost 1, cost 2, or cost 3 Flavor Power. Note that the chances to roll two cost 3 powers in the same flavor is worse than when we used 8 Hyper Tanga Berries to reach the highest budget of 9. Let's say for this example, the second Sweet roll is a cost 2 power, and the second Fresh roll is a cost 3 power.

    Level Budget Cost 1 Power Chance (%) Cost 2 Power Chance (%) Cost 3 Power Chance (%)
    5 19.05 42.86 38.10
  5. In reality, the game will completely roll each flavor before moving on to the next, which is different from how I have presented this. Our rolled costs for each flavor now look like this:

    • Sweet: cost 3, cost 2, cost 1, cost 1, cost 1
    • Spicy: cost 1
    • Sour: cost 1
    • Bitter: cost 1
    • Fresh: cost 3, cost 3, cost 1, cost 1
  6. Next, we'll decide on the total budget of the donut. This sets a limit on the combined costs of all Flavor Powers. The Flavor Score for this donut is 540 + 15 + 25 + 540 = 1120, which hits the highest threshold and gives this donut 9 total budget points to spend. This is enough to accomodate three maximum value Flavor Powers.

    Total Flavor Threshold Total Level Budget
    960 9 points
  7. Now, we can finally decide the Flavor Powers. The game tries to pick the highest value Flavor Powers to assign first. However, we have a tie between Sweet and Fresh: both rolled a cost 3 flavor power, and both have the same 540 points in that flavor. This causes the game to roll to break the tie. We have a 50% chance of the first slot going to Sweet, and a 50% chance of the first slot going to Fresh. Let's say it goes to Sweet.

  8. Which Sweet Flavor Powers are worth 3 points? Similar to in the Hyper Tanga Berry x8 example, the first Flavor Power will be chosen from a pool of 57 Sparkling Powers and three Lv. 3 size powers. We are most likely to pick a random Sparkling Power.

  9. Now, we will roll the second slot. Since the next highest value power is a Fresh power that costs 3 points, the second slot will be chosen from the 18 Catching Power Lv. 3 and Encounter Power Lv. 3, for a total of 19 options. Let's say we roll Encounter Power Lv. 3 in the second slot.

  10. For the third slot, the next highest value power is the second Fresh power that costs 3 points. Since we already have an Encounter Power, this slot is rolled from the 18 Catching Power Lv. 3.

  11. The result might be something like the image below, where the first slot is a Sparkling Power (worth 3 points), the second slot is a Encounter Power Lv. 3 (worth 3 points), and the third slot is a Catching Power Lv. 3 (worth 3 points).

    Haban Rainbow Result: Sparkling + Encounter + Catching

While the mix of flavors is appealing for the Haban Rainbow Donut, this example shows how the equally powerful Sweet and Fresh flavors compete with each other and reduce the chance of desirable combinations. A few factors are at play:

  • If you are aiming to hunt shiny alpha Pokémon, the fact that you could roll 2 Fresh Powers and likely not get an Alpha Power at all cuts the chance of Sparkling + Alpha Power by more than half compared to the Hyper Tanga Berry x8 donut.
  • Another issue is that both Sparkling Power and Catching Power are specific to a Pokémon type. Getting a combination that doesn't work for your target can mean the Catching Power is entirely wasted.
  • The lower starting budget for Sweet gives a 66.67% chance to roll a cost 3 power to start, compared to 100% for the Hyper Tanga Berry x8 recipe. Recall that cost 3 powers are necessary to get Sparkling Power, so you are effectively reducing your chance of being eligible for one.

Here are some more examples of less-than-desirable donuts with this recipe:

Haban Rainbow Result: Catching + Sparkling + Encounter
Haban Rainbow Result: Catching + Alpha + Encounter

Calculator

Denvoros has created a Donut Maker on his website, Rotom Labs: https://rotomlabs.net/legends-z-a/donut-maker

This site can calculate the chance of specific Flavor Powers or good combinations of Flavor Powers based on the berries added. It can also generate a random donut based on these mechanics.

Here is a shareable link to the possible outputs for the Hyper Tanga Berry x8 Donut.

And here is one to the Haban Rainbow Donut.

This calculator implements the research I have described above, so it is the only accurate calculator that exists at the time of writing.

Other Resources

Denvoros has his own analysis and advice on his Donut Mechanics Write-up. This focuses a bit more on gameplay applications than my write-up, which is intended to be technical documentation.

Disassembly

Comments are disabled for this gist.