Algorithm Brief
Summary of the internal CubeX^3 algorithm set
This page consolidates the algorithm notes from the CubeX^3 folder into a single, implementation friendly format. It is intended as a reference for engine design, AI evaluation, and morale mechanics integration.
Algorithm Index
Tensor Field + Tiered Features
Base feature set (v1-v4), tier unlock cadence, sparse board updates, and polarity-driven learning loop. Defines skill points as concurrent cube reads per feature.
RRR Evaluation Core
Risk, Reward, Relation evaluation across material, board control, and morale for turn-level scoring and AI posture selection.
Morale Hierarchy
Unit hierarchy rules for pawns, commanders, generals, and king. Defines morale loss propagation and dual scoring (AI and narrative).
CubeNode State
Board cube data structure for occupancy, threat status, and material weighting for control maps.
Hierarchy Swap + Stance Logic
Linked-chain morale engine, swap-based capture handling, mercenary masking, and stance inference from recent opponent RRR outputs.
Master Piecewise (RRR) Evaluation
Each turn computes three deltas. These map to Offense, Defense, and Strategy labels and drive the AI stance model.
Scoring Bands
The RRR values normalize to -1, 0, +1. Risk uses fixed thresholds. Reward and Relation share a configurable X threshold.
Material Scale Options
Two material value scales appear in the notes. Align on one scale before final tuning. Scale B marks the king as infinite value.
| Piece | Scale A | Scale B |
|---|---|---|
| King | 40 | inf |
| Queen | 12 | 18 |
| Fractal Knight | 9 | 14 |
| Bishop | 6 | 9 |
| Knight | 4 | 8 |
| Rook | 7 | 10 |
| Pawn | 1 | 1 |
Morale Hierarchy System
Morale is hierarchical and cascades upward. Losses ripple from pawn to commander to general to king. Two channels are tracked: AI heuristic morale and narrative morale.
| Role | Morale Value | Notes |
|---|---|---|
| King | 21 | Top of hierarchy, total morale drops to 0 on capture/checkmate. |
| General | 10 | Gold General = Fractal Knight, Silver General = Queen. |
| Commander | 3 | Right flank (gold) and left flank (silver) commanders. |
| Pawn | 1 | Base morale. Loss subtracts from commander and general. |
Linked Chain + Swap Logic
Linked Identity
Each unit stores commander and general IDs. Links are immutable across the match.
Capture Swap
Captured pieces move to a graveyard cache, retaining experience and stats.
Mercenary Mask
If leadership is missing, subordinates mask faction bonuses and revert to base morale.
Rescue
Restoring a leader un-masks subordinates and restores morale contributions.
Board Control Model
Board control scores count all unblocked valid moves for each piece each turn. Additional weighting includes checks and shielded clusters.
CubeNode State
Tensor Field + Tiered Feature System
The AI evaluates a sparse tensor field of 512 cubes. Base features are always active, tiers add higher order pattern detectors, and skill points control how many cubes a feature can read simultaneously.
Sparse Updates + Polarity
Board cubes self report deltas only. The AI updates affected features and computes polarity from snapshot differences to strengthen or prune feature weights.
Stance Inference
Recent RRR outputs are used to classify the opponent posture. The last three labels (Off/Def/Str) map to an aggression profile that biases future move selection.
Source Files
- Cubex^3/ai leveling APD.txt
- Cubex^3/board control.txt
- Cubex^3/Master Piecwise Risk Reward.txt
- Cubex^3/Morale.txt
- Cubex^3/Tf_Algorithm.txt