The configs/ package manages the static data required by the Manue AI for decision-making. Unlike the original CoffeeScript implementation, this Go port embeds JSON data directly into the binary at build time using the go:embed directive. This ensures the agent is self-contained and does not require external file access during execution configs/stats.go40-44
The embedded data covers three primary areas:
Data is loaded at startup via the configs.LoadGameStats() and configs.LoadDangerTree() functions. These functions unmarshal the embedded JSON bytes into Go structures that are then passed as dependencies to the AI configs/stats.go46-55 The data files themselves were originally created by Hiroshi Ichikawa and are included under the project's attribution notice LICENSE32-43
This diagram illustrates how embedded assets flow from the configs package into the core AI logic.
"Configuration Data Flow"
Sources: configs/stats.go40-54 configs/danger_tree.go23-32
The AI uses statistical models to estimate the "future" of a round when it cannot be determined by direct simulation. This includes estimating the probability of an exhaustive draw (ryukyoku) and the expected point swings for various outcomes.
game_stats.json: Contains general round statistics such as numTurnsDistribution (probability of a round ending at a specific turn) and yamitenStats (probability of an opponent being in tenpai without a Riichi call) configs/stats.go27-36light_game_stats.json: Contains the winProbsMap, a large lookup table used to estimate final rank probabilities based on current scores and the remaining rounds configs/stats.go23-25The GameStats struct implements multiple interfaces from the ai package, including WinScoreStats, RoundEndStats, and RankStats, allowing it to be injected directly into the decision engine configs/stats_test.go79-101
For details on the structure and how the AI consumes these fields, see Game Statistics (game_stats.json and light_game_stats.json).
Sources: configs/stats.go27-38 configs/stats_test.go11-70
The danger_tree.all.json file contains a pre-calculated decision tree. The AI uses this tree to calculate hojuProb (deal-in probability) for every tile it considers discarding.
The tree is composed of DecisionNode entities. Each node either:
fonpai, suji, or urasuji) via the FeatureName field configs/danger_tree.go11-21LeafProb if it is a terminal node, representing the statistical danger of that tile category configs/danger_tree.go34-39For details on the tree's node structure and the feature DSL used during traversal, see Danger Tree (danger_tree.all.json).
This diagram maps the data structures in configs/ to the interfaces used by the ai package.
"Danger Data Mapping"
Sources: configs/danger_tree.go11-21 configs/danger_tree.go34-60
During the initialization sequence, the configuration is the first component loaded. If these files are missing or malformed, the unmarshaling process will return an error, preventing the agent from operating with invalid data configs/stats.go48-53
| Function | Data Source | Target Component |
|---|---|---|
LoadGameStats | game_stats.json, light_game_stats.json | ai.ManueAgent |
LoadDangerTree | danger_tree.all.json | ai.DecisionTreeDangerEstimator |