Skip to content

Decouple UI and the engine#22

Merged
apmnt merged 7 commits intomainfrom
15-decouple-ui-and-the-engine
Oct 24, 2025
Merged

Decouple UI and the engine#22
apmnt merged 7 commits intomainfrom
15-decouple-ui-and-the-engine

Conversation

@apmnt
Copy link
Owner

@apmnt apmnt commented Oct 24, 2025

Substantial makeover, rehauled the folder structure and added some new functionality. Now it's possible to pull and execute available actions. This also means that testing is now possible in a sensible way.

@apmnt apmnt requested a review from Copilot October 24, 2025 22:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the codebase to decouple the UI from the game engine, enabling programmatic control and testing without UI dependencies. The new architecture introduces a state module for serialization, an engine module for action discovery and execution, and reorganizes the project structure for better maintainability.

Key changes:

  • Created engine module with get_available_actions() and execute_action() functions to separate action discovery from execution
  • Added state module with immutable state classes for serialization
  • Reorganized code into core, mechanics, and ui packages

Reviewed Changes

Copilot reviewed 36 out of 40 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_simple.py Updated tests to use new engine functions and added comprehensive test suite including bot game tests
setup.py Removed in favor of pyproject.toml
pyproject.toml New build configuration with modern Python packaging standards
pokepocketsim/utils/color_print.py Updated string quotes from single to double
pokepocketsim/ui/gui.py Moved GUI to ui package and updated formatting
pokepocketsim/ui/cli.py New CLI entry point for the application
pokepocketsim/ui/init.py New ui module initialization with conditional GUI import
pokepocketsim/state/*.py New state representation classes for serialization
pokepocketsim/protocols.py Updated imports to use new package structure
pokepocketsim/mechanics/*.py Moved mechanics files and updated imports
pokepocketsim/engine/action_engine.py New engine module implementing decoupled action logic
pokepocketsim/core/*.py Core game objects moved to core package
pokepocketsim/init.py Updated exports for new architecture
examples/*.py New example files demonstrating the refactored architecture
Comments suppressed due to low confidence (1)

tests/test_simple.py:1

  • [nitpick] The logic is inverted compared to the original. Previously if config.debug == False meant "if NOT debug mode, show name only". Now if not config.debug shows name, else shows full action. This preserves the original behavior, but this exact pattern appears in both test file and player.py - consider extracting to a helper function.
import pytest

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@apmnt apmnt merged commit 39ba333 into main Oct 24, 2025
1 check passed
@apmnt apmnt deleted the 15-decouple-ui-and-the-engine branch October 24, 2025 22:54
@apmnt apmnt linked an issue Oct 25, 2025 that may be closed by this pull request
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.

Decouple UI and the engine

1 participant