COM S 327 Programming Project 1.08 Loading Pokemon solution · jarviscodinghub (2024)

Description

We’ve parsed in a number of data files that specify certain details about how to create pokemon. Now ´
we’re actually going to load them into our game. We’ll add the ability to encounter them, but we’ll save
battling and capturing for next week.

We’re going to simplify many of the mechanics of the pokemon main series games (MSGs) in our im- ´
plementation. The full mechanics are just too tedious, which would result in a lot of code and not much
learning. If faithful (or more faithful) mechanics are important to you, you’re welcome to implement something more detailed than presented here.

When walking through tall grass, each move the PC makes has a certain chance of encountering a
pokemon. In the MSGs, different areas of the world will have different kinds of pok ´ emon in the grass, as ´
well as other types of terrain (desert, caves, water) that may spawn pokemon, as well.

We’ll simplify this ´
by allowing any (literally any!) pokemon to spawn in any tall grass, this includes fully evolved forms and ´
legendary and mythical pokemon. We’ve parsed in details on 1092 pok ´ emon; we’ll select from them on a ´
uniform distribution, which means that you have an equal chance of encountering a pidgey and a mewtwo.

As for the probability of encountering a pokemon in the tall grass, something like 10% seems reasonable, ´
but you’re welcome to play with the number.

The levels of encountered pokemon will increase with the manhatten distance from the origin. When ´
distance is less than or equal to 200, minimum level is 1 and maximum level is distance / 2 (integer division).

When distance exceeds 200, minimum level becomes (distance – 200) / 2 and maximum level is 100. With
this formulation, at the origin, all encountered pokemon are level 1, if you go all the way east without going ´
north or south, pokemon are generated at all possible levels, and if you then go all the way north you’ll ´
encounter only level 100 pokemon. ´

Encountered pokemon will know up to two moves. The known moves are restricted to the pok ´ emon’s ´
level-up learnset and will only be less than two if the pokemon has fewer than two moves in its level-up ´
learnset at its level. If a pokemon does not have at least one move in it’s level-up learnset, advance its level ´
to the point where it can learn a move.

The pokemon in our database are grouped in many ways. The ´ version group id in pokemon
moves.csv is a unique identifier of a pokemon game. Theoretically, each game contains all of the ´
pokemon from all of the earlier games, however that ended ended with it Pok ´ emon Sword and Shield in a ´
controversial event that came to be known as Dexit1
.

What this means to us is that there exists no single game
from which we can pull movesets and expect that all pokemon will have a non-empty set. If you want your ´
pokemon to have movesets from a specific game, you may search for a particular ´ version group id;
otherwise, ignore this field.

To find the level-up moveset of a pokemon, you’ll want ´ pokemon moves.pokemon id equal to
pokemon.species id and pokemon moves.pokemon move method id equal to 1. From these,
select your two moves from a uniform distribution.

Pokemon stats (attack, defense, etc.) are given in ´ pokemon stats.csv. The mapping of stat numbers to names is given in stats.csv. Each pokemon has an additive deviation from its species’ base stats, ´
known as IVs (individual values). IVs for each stat are uniformly distributed in the range [0,15]. Generate
IVs for each spawned pokemon for each of HP, attack, defense, speed, special attack, and special defense. ´

https://www.newsweek.com/pokemon-sword-shield-dexit-explained-why-fans-cope-called-monsters-1471237

Pokemon Nerds: If I’m doing something wrong here, please let me know. I have a vague recollection of a past student telling ´
The mechanics of pokemon gender are somewhat involved (designed to reduce storage, see ´
https://bulbapedia.bulbagarden.net/wiki/Individual values). Some pokemon don’t even have genders.

We’ll ´
simplify this by making all species have equal probability of being male or female. As with everything else
here, you’re welcome to implement the more complex mechanic if you like.

Pokemon have a 1/8192 chance of being shiny (a different color than normal), based on their IVs (see ´
the above link). Again, simplify this by ignoring the IVs and simply using, e.g., rand() % 8192 == 0. Feel
free to reduce that modulus to increase your shiny rate.
In order to level up your pokemon, we’ll apply the following formulae: ´
HP =

((base + IV ) × 2) × level
100
+ level + 10
Otherstat =

((base + IV ) × 2) × level
100
+ 5
where base is the pokemon species’ base stat, ´ IV is its IV for the given stat and level is the pokemon’s level. ´

Again, we’re simplifying an MSG mechanic here by ignoring EVs (effort values), which normally add an
additional boost to pokemon growth. See https://bulbapedia.bulbagarden.net/wiki/Stat for the details. ´
When encountering pokemon, we’ll add a placeholder function for the battle and capture sequence in ´
which we’ll print the pokemon’s level, stats, and moves and pause for input (escape, any key, etc.). ´

In order to battle (next week), a trainer must have at least one Pokemon. Create an interface to give the ´
PC the choice of three randomly generated level 1 Pokemon when the game starts. All generated trainers ´
(NPCs) should be given at least one random Pokemon. Assuming the trainer has ´ n Pokemon, there is a 60% ´
probability that the trainer will get an (n + 1)th Pokemon, up to a maximum of 6 Pok ´ emon.

The generated ´
trainers’ Pokemon should be generated with levels and movesets as per the Pok ´ emon generation rules for ´
their map.

You should be giving NPCs pokemon this week, and the trainer-battle placeholder function ´
should be updated to print enough details about the NPCs’s Pokemon that you (and the TAs) can confirm ´
that your Pokemon generation code is working. ´

A final note: There are probably only two of you (maybe three) who know less about pokemon than me. ´
Please let me know if I got something qualitatively wrong here, or if you think of a better simplification to
MSG mechanics than I’ve proposed.
me about IVs going to 32 and a different formula…

COM S 327 Programming Project 1.08 Loading Pokemon solution · jarviscodinghub (2024)
Top Articles
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 6102

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.