INTERNAL ONLY // DEE-TIER 2 // DO NOT DISTRIBUTE
CORE IP // CUBEX^3

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

ai leveling APD

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.

Master Piecewise Risk Reward

RRR Evaluation Core

Risk, Reward, Relation evaluation across material, board control, and morale for turn-level scoring and AI posture selection.

Morale

Morale Hierarchy

Unit hierarchy rules for pawns, commanders, generals, and king. Defines morale loss propagation and dual scoring (AI and narrative).

Board control

CubeNode State

Board cube data structure for occupancy, threat status, and material weighting for control maps.

Tf_Algorithm

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

Risk Reward Relation

Each turn computes three deltas. These map to Offense, Defense, and Strategy labels and drive the AI stance model.

Risk = Opponent Material - Player Material Reward = Opponent Board Control - Player Board Control Relation = Opponent Morale - Player Morale

Scoring Bands

The RRR values normalize to -1, 0, +1. Risk uses fixed thresholds. Reward and Relation share a configurable X threshold.

Risk <= -4 => -1 Risk between -3 and +3 => 0 Risk >= +4 => +1 Reward <= -X => -1 Reward between -X and +X => 0 Reward >= +X => +1 Relation <= -X => -1 Relation between -X and +X => 0 Relation >= +X => +1

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.

Board Control = sum(valid moves of active pieces) + (material value of enemy piece in check) - (material value of player piece in check) + (material value of shielded friendly cluster) - (material value of shielded enemy cluster)

CubeNode State

CubeNode: - position (x,y,z) - isOccupied - occupying_piece - history (last 3 occupancies) - isThreatened / isThreatening - materialValue (dynamic weighting)

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.

Tf = Base[v1..v4] + T1[v1..v4] + T2[v1..v4] + T3[v1..v4] v1: piece enumeration v2: legal move generation v3: heuristic board value v4: action selection

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.

Polarity = f(Delta Tf) Positive polarity -> reinforce features Negative polarity -> decay unused features

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.

Example: Off +1, Off -1, Str 0 => moderately aggressive, mildly tactical Off +1, Off +1, Off +1 => hyper aggressive Off -1, Off -1, Off -1 => hyper retaliatory

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