Headbutt tree: Difference between revisions

→‎Mechanics: Rewriting, using TeX markup | Not sure if the Analysis section is actually that helpful, it's largely based on pre-existing content
(I just kind of thought contain is about something more tangible, like water contained in a glass, non?)
(→‎Mechanics: Rewriting, using TeX markup | Not sure if the Analysis section is actually that helpful, it's largely based on pre-existing content)
Line 9: Line 9:
All headbuttable trees contain wild Pokémon, but different trees have different chances of creating an encounter after Headbutt is used. The headbuttable trees in an area also generate their encounters from different sets of Pokémon depending on whether they have moderate encounter chances or low encounter chances. For example, on {{rt|44|Johto}}, trees with moderate encounter chances may only contain {{p|Spearow}} or {{p|Aipom}}, while trees with a high encounter chance may also contain {{p|Heracross}}.
All headbuttable trees contain wild Pokémon, but different trees have different chances of creating an encounter after Headbutt is used. The headbuttable trees in an area also generate their encounters from different sets of Pokémon depending on whether they have moderate encounter chances or low encounter chances. For example, on {{rt|44|Johto}}, trees with moderate encounter chances may only contain {{p|Spearow}} or {{p|Aipom}}, while trees with a high encounter chance may also contain {{p|Heracross}}.


===Mechanics===
===Encounter mechanics===
Every headbuttable tree can be associated with an index from 0 to 9. Depending on the player's [[Trainer ID number|Trainer ID]], most of those indices correspond to trees with moderate encounter chances, while the rest correspond to trees with a low encounter chance.
The encounter rate and encounter table of each tree depends on the tree's index and the player's [[Trainer ID number]].


A tree's index depends on its X and Y coordinates in the map; that is, its distance from, respectively, the westmost and northmost edges.
The tree's index is an integer from 0 to 9, which depends on its X and Y coordinates on the map—that is, its distance from the westernmost and northernmost edges, respectively. Specifically, the tree's index is calculated using the following formula.


:<code>''index'' = ( ( ''X'' * ''Y'' + ''X'' + ''Y'' ) / 5 ) [[wp:modulo operation|%]] 10</code>
:<math>TreeIndex = \left\lfloor \frac{X \cdot Y + X + Y}{5} \right\rfloor \bmod 10</math>


To gain some insight into this formula, it is possible to "fix" one dimension and traverse the other, since ''X'' and ''Y'' are freely interchangeable. Substituting "Z" for one axis (the fixed axis) and "n" for the other (the axis that will be traversed), the formula becomes:
The encounter rate and tree type depends on the last digit of the player's Trainer ID.
:<code>( ( ''Z'' * ''n'' + ''Z'' + ''n'' ) / 5 ) % 10</code>
* If a tree's index is equal to that ID digit, the tree is a "high-encounter tree" and its encounter rate is 80%.
which then becomes:
* If the tree's index is one of the next four indices after that ID digit (wrapping back around to 0 after 9), the tree is a "moderate-encounter tree" and its encounter rate is 50%.
:<code>( ( (''Z'' + 1) * ''n'' + ''Z'' ) / 5 ) % 10</code>
* Otherwise, the tree is a "moderate-encounter tree" and its encounter rate is 10%.


This result shows that, if a single row or column of trees is traversed (i.e., if ''n'' changes), moving from one tree to the next changes the index (before the modulo operation) by <code>(''Z'' + 1) / 5</code>, where ''Z'' is the distance of that row or column from its origin edge (north or west). In short, the closer a row or column is to the edge (the smaller ''Z'' is), the slower the indices of those trees will change as the row or column is traversed.
====Encounter rate by index and Trainer ID====
The following is a table depicting the encounter rate of the tree, based on the tree index and the last digit of the player's Trainer ID. Tree indexes are displayed in rows, while Trainer ID digits are displayed in columns.


The encounter chances associated with a tree of a given index are determined by a "pivot" index determined by the player's Trainer ID (specifically, the rightmost digit of the player's Trainer ID).
An 80% encounter rate indicates the tree is a "high-encounter tree". Otherwise it is a "moderate-encounter tree".


:<code>''pivot'' = ''trainer_id'' % 10</code>
{| class="wikitable"
!
! 0 !! 1 !! 2 !! 3 !! 4 !! 5 !! 6 !! 7 !! 8 !! 9
|-
! 0
| 80% || 10% || 10% || 10% || 10% || 10% || 50% || 50% || 50% || 50%
|-
! 1
| 50% || 80% || 10% || 10% || 10% || 10% || 10% || 50% || 50% || 50%
|-
! 2
| 50% || 50% || 80% || 10% || 10% || 10% || 10% || 10% || 50% || 50%
|-
! 3
| 50% || 50% || 50% || 80% || 10% || 10% || 10% || 10% || 10% || 50%
|-
! 4
| 50% || 50% || 50% || 50% || 80% || 10% || 10% || 10% || 10% || 10%
|-
! 5
| 10% || 50% || 50% || 50% || 50% || 80% || 10% || 10% || 10% || 10%
|-
! 6
| 10% || 10% || 50% || 50% || 50% || 50% || 80% || 10% || 10% || 10%
|-
! 7
| 10% || 10% || 10% || 50% || 50% || 50% || 50% || 80% || 10% || 10%
|-
! 8
| 10% || 10% || 10% || 10% || 50% || 50% || 50% || 50% || 80% || 10%
|-
! 9
| 10% || 10% || 10% || 10% || 10% || 50% || 50% || 50% || 50% || 80%
|}


If a tree's index matches the pivot index, its encounter chances are 80%; the next four tree indices (effectively, <code>( ''pivot'' + ''n'' ) % 10</code>, where ''n'' = 1...4) have encounter chances of 50%; and the remaining indices have encounter chances of 10%. The 10% and 50% indices make up the "moderate" encounter chances referred to above, and share a common set of Pokémon from which encounters are created, while the 80% indices draw from a different set of Pokémon for encounters.
====Analysis====
Since X and Y are interchangeable in the tree index formula, it is possible to "fix" one dimension to consider traveling along the other. Substituting "Z" for the fixed axis and "n" for the axis that will be traversed, the formula becomes:
:<math>
\begin{align}
TreeIndex &= \left\lfloor \frac{Z \cdot n + Z + n}{5} \right\rfloor \bmod 10 \\
&= \left\lfloor \frac{(Z + 1) \cdot n + Z}{5} \right\rfloor \bmod 10
\end{align}
</math>
 
This result shows that, if a single row or column of trees is traversed, moving to an adjacent tree increases the tree's index by <math display="inline">\tfrac{Z + 1}{5}</math> (modulo 10), where ''Z'' is the distance of that row or column from its origin edge (north or west). This means that the closer a row or column is to the edge, the slower the indices of those trees change as the row or column is traversed.


===Pokémon===
===Pokémon===