How citrus610/ama works
Main Components
• AI Engine (ai folder): This is the heart of the project, where decision-making happens. Parse out the following submodules:
– Evaluation (eval.cpp/h): Responsible for assessing board positions.
– Form (form.cpp/h): Contains the logic for human-like chain formations.
– Gaze (gaze.cpp/h): Implements the opponent field “gazing” feature.
– Move and Path (move.cpp/h, path.cpp/h): Likely determine move sequences and board navigation.
– Search (ai/search folder): Houses different search algorithms – attack, build, and quiet search – each aimed at maximizing chain potential or tactical advantages.
• Core Game Logic (core folder): This holds the bitfield implementation and core data structures:
– Field representation (field.cpp/h, fieldbit.cpp/h)
– Essential definitions and directions (def.h, direction.h, cell.h, core.h)
This layer abstracts the state of the Puyo Puyo board and is used extensively by the AI engine.
• Client Application (puyop folder): Contains the main application (main.cpp) that starts the game and integrates the AI.
• Tuning Module (tuner folder): Provides the interface for parameter tuning (score.h, tuner.h, main.cpp) to optimize AI performance.
• Testing (test folder): Contains test harnesses that ensure the correctness of different system modules.
• External Dependencies:
– The JSON library (in lib/nlohmann) for configuration parsing.
– A configuration file (config.json) that likely sets parameters for AI behavior (e.g., enabling/disabling human-like chains).
Relationships and Data Flow
• The PuyoPuyo Client uses the Core Game Logic to maintain a representation of the game state.
• This state is fed into the AI Engine (evaluation, move generation, and search modules) which computes the strategic move.
• The Search submodules (attack, build, quiet) work under the umbrella of the AI Engine to simulate various strategies.
• The Tuner module operates either independently or in conjunction with the AI modules for parameter optimization and adjustments.
• External configurations (config.json) and JSON parsing via nlohmann are integrated into the initialization process to adjust AI parameters.
• The Testing suite validates the integrity of modules across layers.
Architectural Patterns and Design Principles
• Separation of Concerns: Each folder (ai, core, puyop, tuner, test) represents a distinct concern, from decision-making to game state management.
• Modularity: The division into submodules (especially in the ai folder with its dedicated search algorithms) suggests a plug-and-play style—each component can be updated or replaced without impacting others.
• Efficient Data Structures: The core’s bitfield implementation is central to performance and hints at using low-level optimization.
• Configuration-Driven Behavior: With a dedicated config.json and a third-party JSON library, the AI’s behavior is adjustable even post-compilation.