Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Some Values To Pokemon Game Wrapper #374

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wpeguero
Copy link

@wpeguero wpeguero commented Mar 4, 2025

Added number of pokemon in party, total game time, total number of items, and whether the pokemon trainer is in battle or not.

The purpose of these parameters is to help the user of the game wrapper train AI agents by either switching model between exploration mode and battle mode, to provide insight of in-game time, to provide rewards based on the number of pokemon in party and to observe the number of items gathered while playing the game.

The purpose of these values is to allow the machine learning model to
gain information that it would not know of without it being complex.

Currently there is only access to the total number of items to provide
agents to some information in regards to their items.

The total number of pokemon in the party will allow the user to provide
rewards based on the number of pokemon the agent has gathered.

The time will provide the user with some insight as to how many in game
hours the model took to reach certain check points or flags found within
the game.

Added a battle state variable which will allow the user to either use
models that are specific to the battle scenarios within the game and the
game overworld.

Currently working on developing the flags for the badges. Have added it
on for now.
When the game wrapper is called upon, it now prints out the number of
pokemon in the party, the amount of time spent in game, the total number
of items in backpack as well as whether the pokemon trainer is in battle
or in the overworld.
Copy link
Owner

@Baekalfen Baekalfen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Looks good, but I've added a few comments.

Comment on lines +83 to +86
if self.pyboy.memory[ADDR_BATTLE] == 1:
self.battle_state = 'In Battle'
else:
self.battle_state = 'Overworld'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? I think there's some distinction between trainer battle and wild pokémon.

Comment on lines +48 to +65
if self.pyboy.memory[ADDR_TITLE_SCREEN] == 0:
pass
else:
self.number_of_pokemon = self.pyboy.memory[ADDR_NUMBER_OF_POKEMON]
self.total_items = self.pyboy.memory[ADDR_TOTAL_ITEMS]
# Extract the time in game:
_hours = self.pyboy.memory[ADDR_HOURS]
_minutes = self.pyboy.memory[ADDR_MINUTES]
_seconds = self.pyboy.memory[ADDR_SECONDS]
self.game_time = f'{_hours}:{_minutes}:{_seconds}'

# Check whether the player is in battle mode or out of battle
if self.pyboy.memory[ADDR_BATTLE] == 1:
self.battle_state = 'In Battle'
else:
self.battle_state = 'Overworld'

self.badges = self.pyboy.memory[ADDR_BADGES] #Research how this works.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all duplicate code. Better just define some default value (0) for all of them. The data of the game wrapper classes are not valid before calling pyboy.tick() anyway.

Comment on lines +77 to +78
_hours = self.pyboy.memory[ADDR_HOURS]
_minutes = self.pyboy.memory[ADDR_MINUTES]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see from datacrystal which you link to, that hours and minutes are two bytes. You'll need to check how this works.

@wpeguero
Copy link
Author

wpeguero commented Mar 6, 2025

Hi Baekalfen,

Thank you for the comments I did do some print outs, but was a little bit confused on the placement of code and how things worked. Will definitely do some testing on this and convert it this pull request to a draft in the meantime.

@wpeguero wpeguero marked this pull request as draft March 6, 2025 13:10
@Baekalfen
Copy link
Owner

Hi Baekalfen,

Thank you for the comments I did do some print outs, but was a little bit confused on the placement of code and how things worked. Will definitely do some testing on this and convert it this pull request to a draft in the meantime.

All good. Come to Discord if you need help. There are more people than just me who'd know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants