Monster Rancher 2 Monster AI Processing
What goes into the game's AI that makes a monster choose what to do during a fight? SmilingFaces96 breaks down A.I. processing for Monster Rancher 2.Background On Distance Parameters and Formulas
A battle takes place in a fixed arena length. Each monster’s in-arena-position is considered where its backside is currently at. The in-arena-position is in respect to the center of the arena, position 0. Each monster starts the battle at the same relative fixed position from the center. Each monster has a base length that is modified based on its current life stage length percentage. There are 3 life stage length percentages for battle: 70% (life stage 1-2), 90% (life stage 3-4), and 100% (life stage >4). There is an area between the monsters that will be referred to as a dead zone. The monsters can never physically get closer than the dead zone to each other.
- Arena Length: 6000 (-3000 to 3000 position wise)
- Monster 1 Start Position: -1950 (left)
- Monster 2 Start Position: 1950 (right)
- Dead Zone: 500
Monster Type | Base Length | Monster Type | Base Length | Monster Type | Base Length |
---|---|---|---|---|---|
Ape | 450 | Golem | 914 | Naga | 720 |
Arrow Head | 943 | Hare | 331 | Niton | 200 |
Bajarl | 332 | Henger | 364 | Phoenix | 650 |
Baku | 1150 | Hopper | 232 | Pixie | 125 |
Beaclon | 1160 | Jell | 460 | Plant | 550 |
Centaur | 450 | Jill | 565 | Suezo | 270 |
ColorPandora | 1138 | Joker | 783 | Tiger | 640 |
Dragon | 800 | Kato | 400 | Undine | 165 |
Ducken | 220 | Metalner | 280 | Worm | 820 |
Durahan | 375 | Mew | 250 | Wracky | 254 |
Gaboo | 540 | Mocchi | 250 | Zilla | 460 |
Gali | 220 | Mock | 873 | Zuum | 820 |
Ghost | 220 | Monol | 100 | *See Appendix for length sorted |
M1/2_Mod_Length = Base Length x Life Stage Length Percentage
(MBD) Distance between Monsters: M2_Posiiton - M1_Position - Dead Zone - M1_Mod_Length - M2_Mod_Length
(M1ED/MED) Monster 1 Distance from Edge: 3000 + M1_Position
(M2ED/MED) Monster 2 Distance from Edge: 3000 - M2_Position
(MPD) Monster Push Distance: <= 50 MBD
(MT1D) Monster Technique Close Distance: <= 400 MBD
(MT2D) Monster Technique Short Distance: > 400 MBD to <= 1000 MBD
(MT3D) Monster Technique Middle Distance: > 1000 MBD to <= 1800 MBD
(MT4D) Monster Technique Far Distance: > 1800 MBD to <= 2800 MBD
Background on Monster AI Selection Options
During battle, the Monster AI has 5 possible options. Those 5 options are 1) Execute technique (EXECUTE), 2) PUSH BACK, 3) WAIT, 4) Move towards other monster (FORWARD), and 5) Move away from other monster (BACKWARD). Each option is executed to completion before choosing another option. While executing options 3, 4, or 5, the monster will also adjust what techniques it currently has selected for each attacking range. While dodging an attack, the monster will pause its waiting or moving until the dodge is finished, then continue execution of the wait or move. The Monster AI selection is executed at a rate of 30 times a second, but will be interrupted during completion of attacks, push backs, foolery, and dodges.
Choosing Selected Techniques
As stated in the previous section, during the execution of the waiting or moving state, the monster AI will attempt to change its currently selected technique range or modify its currently selected technique for the currently selected range. Each time the monster is executing its move or waiting, there is a 12.5% chance that an attempt will be made to change the technique selected or technique range selected, with each option having an equal chance of execution.There are 4 options for the monster when trying to select new techniques or ranges: 1) Move selected technique range to the right, 2) Move selected technique range to the left, 3) select next technique at currently selected range, or 4) select previous technique at currently selected range. Whether moving left, right, increasing or decreasing, the options will wrap around (i.e. changing selected technique ranges to the right will cause moving from far right to wrap around to the far left).
Choosing a technique at the currently selected range is pretty self-explanatory. If this option is selected, the technique at the currently selected attacking range will increase to the next technique or decrease to the previous technique if a technique is available to do so.
For choosing a technique attacking range, the range selected will only stop on ranges that have active techniques; therefore, the AI monster technique range selector should never stop on a range with no techniques.
Populating AI Options
Before executing an AI selected option, the options to choose from need to be determined for this selection moment. The possible options are populated based on the current monster’s position and the technique that it could potentially execute.The first option that is populated is chosen based on the following criteria: Monster distance to edge (MED), Distance between monsters (MBD), and technique existence at current range.
- If MED < 100 AND MBD <= 50, then PUSH BACK is populated as the first option; otherwise, if no technique exists at the current range, then FORWARD is populated as the first option; otherwise, WAIT is chosen as the first populated option.
- If MBD > 0, then FORWARD is chosen as the next populated option; otherwise, nothing is chosen as the next option. Note: there could be two FORWARD choices in the populated options depending on how the first option was populated.
- If MED > 80, then BACKWARD is chosen as the next populated option; otherwise, nothing is chosen as the next option.
- IF MED < 1500 AND MBD <= 50, then PUSH BACK is selected as the next option; otherwise, nothing is chosen as the next option. Note: there could be two PUSH BACK choices in the populated options depending on how the first option was populated.
If there is no technique at the current range or there are not enough guts to execute the current technique, then zero EXECUTE options will be populated as possible options.
- EXECUTE populate method #1: This method will be used if the current technique that is at the monster range is a life recovery technique that cannot do any guts damage or life damage to the opposing monster.
-
Before Limit Amount = 10 + 2 x ( 10 x life_left_opp / start_life_opp ) - 3 x ( 10 x life_left / start_life )
Before Limit Amount = | 10 + 2 x ( 10 x 300 / 599 ) - 3 x ( 10 x 240 / 800 ) |
10 + 2 x ( 3000 / 599 ) - 3 x ( 2400 / 800 ) | |
10 + 2 x 5 - 3 x 3 -> 10 + 10 - 9 -> 11 |
Since 11 does not cause the amount of 16 possible options to be exceeded (since the maximum previous options selected cannot exceed 4 [4 + 11 = 15]), then 11 EXECUTE options will be added to possible AI options.
If the amount calculated above was <= 0, then zero EXECUTE options would have been added.
Observations: The greater life you have -> less options will be added; the greater the opponent’s life -> more options will be added. For every 10% of life you have left, 3 options will be subtracted. For every 10% of life your opponent has left, 2 options will be added.
- EXECUTE populate method #2: This method will be used if the current technique that is at the monster range will potentially do guts or life damage – this method will be used the most. The number of EXECUTE options that will be added is calculated as follows (all divisions round down):
- If opponent monster is in foolery, then “Guts Factor = Guts - 25”; otherwise, “Guts Factor = Guts - 40”.
- Before Limit Amount = Guts Factor / 5
- Before Limit Amount = (94 – 25) / 5 -> 69 / 5 -> 13
- Since 13 causes the amount of 16 possible options to be exceeded (since the previous options selected count was 4 [4 + 13 = 17]), then 12 EXECUTE options will be added to possible AI options.
Observations: The greater guts the monster has, the more EXECUTE options it will have.
The option that is selected to run is randomly selected based on the small random number generator (0-255 order continuously repeats) from the options that were populated from the previous selection criteria.
- Populating Options Example: The following options were populated as a result of the previous selection possibilities: WAIT, FORWARD, BACKWARD, EXECUTE, EXECUTE, EXECUTE; therefore
- Percent Chance for each would then be: 16.6% WAIT, 16.6% FORWARD, 16.6% BACKWARD and 50% EXECUTE
Running Selected AI Option
- PUSH BACK – This option is pretty self-explanatory, the monster will execute a push back move.
- EXECUTE – The monster will first determine if foolery will activate. If foolery will activate, then the monster will be in FOOLERY; otherwise, the monster will execute the selected technique at the current range.
- WAIT – The monster will select between a 0, 1, or 2 second time delay, and then wait that amount of time. The number is chosen using the small random number generator.
- FORWARD – The monster will begin moving towards the opposing monster. A distance amount will be initialized based on BMD, then decremented by the monster’s Arena Movement Rate every Monster AI execution until the amount is less than or equal to 0. At that time the monster will stop moving.
- % is the modulo/remainder function
- LRN = Large Random Number (0-32767, next value can be the same)
- Initial Move Value = (LRN % (BDM / 64)) x 64 [round down]
- Example: LRN = 33, BDM = 1000, Arena Movement Rate = 32
Plug into formula -> (33 % ( 1000 / 64 )) x 64
(33 % 15) x 64 -> 3 x 64 -> 192 - Number of steps taken = Initial Move Value / Arena Movement Rate = 192 / 32 = 6 steps [round up]
- Amount of time taken = 6 steps x 1 second /30 steps = 0.2 seconds
- Final distance traversed = 6 steps x 32 distance / step = 192 distance (equates to 3.2% of the arena)
- Example: LRN = 33, BDM = 1000, Arena Movement Rate = 32
- BACKWARD – The monster will begin moving away from the opposing monster. A distance amount will be initialized based on MED, then decremented by the monster’s Arena Movement Rate every Monster AI execution until the amount is less than or equal to 0. At that time the monster will stop moving.
- % is the modulo/remainder function
- LRN = Large Random Number (0-32767, next value can be the same)
- Initial Move Value = (LRN % (MED / 64)) x 64 [round down]
- Example: LRN = 900, MED = 700, Arena Movement Rate = 28
Plug into formula -> (939 % ( 700 / 64 )) x 64
(939 % 10) x 64 -> 9 x 64 -> 576 - Number of steps taken = Initial Move Value / Arena Movement Rate = 576 / 28 = 21 steps [round up]
- Amount of time taken = 21 steps x 1 second / 30 steps = 0.7 seconds
- Final distance traversed = 21 steps x 28 distance / step = 588 distance (equates to 9.8% of the arena)
- Example: LRN = 900, MED = 700, Arena Movement Rate = 28
Appendix – Monster Type Base Length sorted by base length
Monster Type | Base Length | Monster Type | Base Length | Monster Type | Base Length |
---|---|---|---|---|---|
Beaclon | 1160 | Jill | 565 | Suezo | 270 |
Baku | 1150 | Plant | 550 | Wracky | 254 |
ColorPandora | 1138 | Gaboo | 540 | Mew | 250 |
Arrow Head | 943 | Jell | 460 | Mocchi | 250 |
Golem | 914 | Zilla | 460 | Hopper | 232 |
Mock | 873 | Ape | 450 | Ducken | 220 |
Worm | 820 | Centaur | 450 | Gali | 220 |
Zuum | 820 | Kato | 400 | Ghost | 220 |
Dragon | 800 | Durahan | 375 | Niton | 200 |
Joker | 783 | Henger | 364 | Undine | 165 |
Naga | 720 | Bajarl | 332 | Pixie | 125 |
Phoenix | 650 | Hare | 331 | Monol | 100 |
Tiger | 640 | Metalner | 280 |
Appendix – Glossary of terms and Definitions
Arena Length: 6000 (-3000 to 3000 position wise)Monster 1 Start Position: -1950 (left)
Monster 2 Start Position: 1950 (right)
Dead Zone: 500 -distance between monsters that cannot be crossed. This will be subtracted out when determining technique ranges and such.
M1ED/MED - Monster 1 Distance from Edge: 3000 + M1_Position
M2ED/MED - Monster 2 Distance from Edge: 3000 - M2_Position
MPD - Monster Push Distance: <= 50 MBD
MT1D - Monster Technique Close Distance: <= 400 MBD
MT2D - Monster Technique Short Distance: > 400 MBD to <= 1000 MBD
MT3D - Monster Technique Middle Distance: > 1000 MBD to <= 1800 MBD
MT4D - Monster Technique Far Distance: > 1800 MBD to <= 2800 MBD
LRN – Large Random Number (0-32767, next value can be the same)
SRN – Small Random Number (0-255, order continuously repeats)