Skip to content

Add game wrapper for 2048 (homebrew)#418

Open
poullakkos wants to merge 8 commits into
Baekalfen:masterfrom
poullakkos:game-wrapper-2048
Open

Add game wrapper for 2048 (homebrew)#418
poullakkos wants to merge 8 commits into
Baekalfen:masterfrom
poullakkos:game-wrapper-2048

Conversation

@poullakkos
Copy link
Copy Markdown

@poullakkos poullakkos commented May 14, 2026

Adds a game wrapper for the 2048 homebrew Game Boy game by wyattferguson.
MD5: 6748719720d57a7dce48d07b2f3c5ede
SHA256: a5dd7ad505baf13bdf66736518c2d6708459c3aaf1ed2d2282f05c2d1d958d9c

The wrapper provides:

  • score
  • board (5x5 grid)
  • winner (reached 2048)
  • game_over()

Tests included in tests/test_2048.py

@poullakkos poullakkos changed the title Add game wrapper for 2048 (homebrew)! Add game wrapper for 2048 (homebrew) May 14, 2026
@Baekalfen
Copy link
Copy Markdown
Owner

Awesome, I’ll get back to you asap, but it’ll take some days

@Baekalfen
Copy link
Copy Markdown
Owner

Can you point me to the ROM you used? The one here has a different MD5: 6748719720d57a7dce48d07b2f3c5ede

@poullakkos
Copy link
Copy Markdown
Author

Thanks for pointing that out! It seems I had an older version of the ROM. I've updated the wrapper to use the official ROM from wyattferguson's repository (MD5: 6748719720d57a7dce48d07b2f3c5ede). The memory addresses are the same so the wrapper works correctly.

Comment thread pyboy/plugins/manager.py
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

several unrelated formatting changes have been added, do see if these can be cleaned up.

for p in sorted(list(set(plugins) - set(game_wrappers))):
p_name = to_snake_case(p)
spec = importlib.util.spec_from_file_location(
p_name, os.path.dirname(os.path.abspath(__file__)) + "/" + p_name + ".py"
Copy link
Copy Markdown

@bhaskar253 bhaskar253 May 23, 2026

Choose a reason for hiding this comment

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

here as well unrelated formatting changes have been introduced

Comment thread tests/conftest.py
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unrelated formatting changes have been added, please remove them

Copy link
Copy Markdown

@bhaskar253 bhaskar253 left a comment

Choose a reason for hiding this comment

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

several unrelated formatting changes have been added, please do avoid them

@poullakkos
Copy link
Copy Markdown
Author

Thanks for the feedback! The formatting issues were caused by the Black formatter I had enabled in my editor. I've disabled it and fixed all the formatting. Sorry for the noise!

Copy link
Copy Markdown
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.

Short and sweet. Really nice work. Nothing functionally needed (if tests pass).

I've add the 2048 ROM to my mirror and added it to the conftest, so it automatically downloads it.

Comment on lines +20 to +26
try:
with open(self.pyboy.gamerom_file, "rb") as f:
rom_hash = hashlib.md5(f.read()).hexdigest()
return rom_hash == "6748719720d57a7dce48d07b2f3c5ede"
except Exception as e:
logger.error(f"Error occurred while checking ROM hash: {e}")
return False
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I can see the game ROM is missing a title, and that's why you do this. I've tried raising the issue with the author: wyattferguson/2048-gb#1

self.winner = self.pyboy.memory[0xC0F3] == 1

state = self.pyboy.memory[0xC0F4]
self._game_over = state == 3
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What is "3"? You should define this magic number as a constant. Are there other interesting states to document?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It would be nice if you made all of your addresses constants too, with a meaningful name.

@Baekalfen Baekalfen force-pushed the game-wrapper-2048 branch from e095403 to 846a7d2 Compare May 29, 2026 19:52
@Baekalfen
Copy link
Copy Markdown
Owner

Baekalfen commented May 29, 2026

I can see the tests are failing, but you can find the results in the runner outputs

EDIT:
Maybe the output is not public, but you can run it locally

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.

3 participants