How anselchang/tetrisfish works
Main Components
• Main Application: Represented by main.py, which orchestrates the initialization and coordination of core modules.
• User Interface (UI) Module: Built on Pygame, this includes assets from the Images folder and modules like PygameButton.py to handle user interactions and rendering.
• Board Analysis Engine: Consisting of Analysis.py, AnalysisBoard.py, AnalysisConstants.py, EvalGraph.py, Evaluator.py, and TetrisUtility.py. This component is responsible for processing board states, running analysis algorithms, and determining mistakes.
• Calibration Engine: Split between Callibration.py (with its unique naming) and the calibrate directory containing modules such as autofindfield.py, autolayout.py, blockmatch.py, etc. This system adjusts for variances in board images and ensures proper extraction of board states.
• Video/Rendering Module: Involves RenderVideo.py and possibly Render from the Images folder, handling the display and post-processing of video data.
• External Communication: Although not represented by a separate file, the README emphasizes that a stable internet connection is needed for the API communication with StackRabbit. This should be highlighted as a connector or adapter that links the analysis engine with the external Tetris AI.
• Bundling and Build Scripts: The bundle directory and files such as build scripts (build_mac_os.sh, build_windows.ps1, etc.) reflect deployment and packaging concerns.
Relationships and Data Flow
• Calibration Engine back to the Analysis Engine to show that accurate board state extraction depends on the calibration process.
• Out the dependency of the main application (main.py) to all modules, emphasizing it as the orchestrator.
• Utility functions and supporting modules as sub-components that feed into the analysis process.
Architectural Patterns and Design Principles
• Separation of Concerns: Clearly separate the visualization (UI), processing (analysis/evaluation), and calibration (image correction) portions.
• Modularity: Note that functionalities (such as calibration and board analysis) are implemented in isolated modules, making them replaceable or upgradable. Each module is responsible for a specific set of tasks.
• External Integration: Emphasize the API connector with StackRabbit, showing how the system is designed to extend its capabilities via external services.