Backend & Chain/Scoring Engine
GitHub

Scoring Engine

Complete reference for all scoring algorithms, formulas, and thresholds.

24,502

Star Systems

scored per cycle

5

Trust Dimensions

per player

6

CHI Sub-Indices

weighted composite

5

Alert Types

anomaly patterns

Consistency Guarantee

The same scoring formulas run in three places: the oracle backend (scoring.ts), the frontend live data module (liveData.ts), and the Sui smart contract (frontier_pulse.move). This ensures consistent scores regardless of which path produces them.

System Health Scoring

Each of the 24,502 star systems receives a health snapshot. When real enrichment data (smart assemblies, killmails) is available from the World API, it drives the scores. Otherwise, a deterministic hash function provides consistent fallback scores.

Real Data Path

Inputs from World API enrichment:

InputSourceDescription
playerCountSmart Assemblies + KillmailsUnique player addresses active in system
infraCountSmart Assemblies APINumber of deployed Smart Assemblies (gates, SSUs, turrets)
killsKillmails APIRecent PvP kill count in this system
scoring.ts — System Health
// Step 1: Component scores (0-100 each)
playerScore  = min(playerCount * 5, 100)
infraScore   = min(infraCount * 3, 100)
combatScore  = min(kills * 8, 100)

// Step 2: Activity Level — weighted blend
activityLevel = clamp(
  playerScore * 0.4 + infraScore * 0.35 + combatScore * 0.25
)

// Step 3: Trust Level — inverse of combat ratio + infrastructure bonus
combatRatio = playerCount > 0 ? kills / playerCount : 0
baseTrust   = clamp(100 - combatRatio * 50)
infraBoost  = min(infraCount * 2, 20)
trustLevel  = clamp(baseTrust + infraBoost)

// Step 4: Transaction Frequency — activity density proxy
txFrequency = clamp((playerCount * 3 + infraCount * 2 + kills) * 2)

// Step 5: Local CHI — 40% activity + 60% trust (trust-weighted)
localChi = floor((activityLevel * 40 + trustLevel * 60) / 100)
Activity Level

players×0.4 + infra×0.35 + combat×0.25

72
Trust Level

100 - combatRatio×50 + infraBoost

85
Local CHI

activity×40% + trust×60%

79

Deterministic Fallback

When no enrichment data exists, a seeded hash function generates consistent pseudo-random scores from the system ID:

vitals.ts — Hash Function
function hash(n: number): number {
  let h = n ^ 0x5f3759df;
  h = Math.imul(h ^ (h >>> 16), 0x45d9f3b);
  h = Math.imul(h ^ (h >>> 13), 0x45d9f3b);
  h = (h ^ (h >>> 16)) >>> 0;
  return (h & 0xffff) / 0xffff;  // → 0.0 to 1.0
}

// Same system ID always produces the same vitals:
activityLevel = floor(10 + hash(systemId) * 90)           // 10-100
trustLevel    = floor(15 + hash(systemId + 7919) * 85)    // 15-100
playerCount   = floor(hash(systemId + 15373) * 60)        // 0-60
infraCount    = floor(hash(systemId + 23197) * 20)        // 0-20
txFrequency   = floor(10 + hash(systemId + 31531) * 90)   // 10-100
combatIncidents = floor(hash(systemId + 40343) * 12)      // 0-12
The hash offsets (7919, 15373, etc.) are prime numbers chosen to minimize correlation between dimensions for the same system.

Player Reputation (Trust Compass)

Each player's on-chain activity is analyzed across 5 behavioral dimensions (0-100 each):

scoring.ts — Player Reputation
// Inputs from World API aggregation:
//   assemblyCount  — Smart Assemblies owned by this player
//   killCount      — Times this player was the attacker
//   deathCount     — Times this player was the victim
//   systemsVisited — Unique systems with activity

totalCombat     = killCount + deathCount
aggressionRatio = totalCombat > 0 ? killCount / totalCombat : 0

// 5 Dimensions:
reliability  = clamp(40 + assemblyCount * 5 + systemsVisited * 2)
commerce     = clamp(30 + assemblyCount * 8)
diplomacy    = clamp(50 - aggressionRatio * 40 + systemsVisited * 3)
stewardship  = clamp(20 + assemblyCount * 10)
volatility   = clamp(totalCombat * 5 + |killCount - deathCount| * 3)

Trust Compass Dimension Weights

25%
25%
20%
20%
10%
Reliability (25%)
Commerce (25%)
Diplomacy (20%)
Stewardship (20%)
Inv. Volatility (10%)

Composite Trust Score

Weighted combination matching the on-chain formula:

On-chain formula
composite = (
  reliability * 25 +
  commerce    * 25 +
  diplomacy   * 20 +
  stewardship * 20 +
  (100 - volatility) * 10   // inverted: low volatility = good
) / 100

Archetype Classification

First matching rule wins:

ArchetypeRuleDescription
Civilization Builderstewardship ≥ 80 AND reliability ≥ 70Builds infrastructure for others
Trusted Tradercommerce ≥ 80 AND reliability ≥ 70Reliable economic participant
Diplomatdiplomacy ≥ 75 AND volatility < 30Brings people together peacefully
Warlordvolatility ≥ 70 AND commerce < 40Combat-focused, low trade
Wildcard50 ≤ volatility < 70Unpredictable behavior
NewcomerdefaultInsufficient data for classification

Civilization Health Index (CHI)

The global CHI aggregates all system health scores into a single composite (0-100) using 6 weighted sub-indices:

CHI Sub-Index Weights

20%
15%
15%
15%
20%
15%
Economic Vitality (20%)
Security Index (15%)
Growth Rate (15%)
Connectivity (15%)
Trust Index (20%)
Social Cohesion (15%)
scoring.ts — Global CHI
// Inputs: all system health scores from current cycle

economicVitality = avg(txFrequency) * 0.6 + avg(infraCount * 5) * 0.4
securityIndex    = clamp(100 - avg(combatIncidents) * 8)
growthRate       = (systemsWithActivity>50 / totalSystems) * 100
connectivity     = avg(activityLevel) * 1.1
trustIndex       = avg(trustLevel)
socialCohesion   = trustIndex * 0.4
                 + securityIndex * 0.3
                 + min(avg(playerCount) * 3, 100) * 0.3

// Weighted overall (matches on-chain):
overall = (
  economicVitality * 20 +
  securityIndex    * 15 +
  growthRate       * 15 +
  connectivity     * 15 +
  trustIndex       * 20 +
  socialCohesion   * 15
) / 100

Diagnosis Thresholds

ScoreDiagnosisMeaning
≥ 80FlourishingPeak civilization — high activity, high trust, growing
≥ 65ThrivingStrong and healthy, minor issues
≥ 50StableFunctional but not exceptional
≥ 35StressedCracks showing — trust or security concerns
≥ 20DecliningSignificant deterioration across metrics
< 20CollapsingCivilization is failing

Anomaly Detection

Each oracle cycle scans system scores against pattern rules. Alerts are emitted as on-chain events (not stored, for gas efficiency).

Alert TypeTrigger ConditionSeverityOn-Chain Code
Blackoutinfra > 5 AND activity < 10Critical (0)AnomalyAlertEmitted
Trust Collapsetrust < 20 AND players > 5High (1)AnomalyAlertEmitted
Combat HotspotcombatIncidents > 8Medium (2)AnomalyAlertEmitted
Trade Spiketx > 85 AND players > 20Warning (3)AnomalyAlertEmitted
Infrastructure HubinfraCount > 5Info (4)AnomalyAlertEmitted
The frontend's liveData.ts also generates additional summary alerts (Population Center, Warzone, Civilization Core, Census Update) from aggregate statistics.

Color Mapping

Trust scores map to a consistent color palette across all visualizations:

Trust Level Spectrum

0Hostile40Stressed70Healthy100
lib/colors.ts
// Trust colors (galaxy nodes, compass, badges)
trust >= 70 → green  (#00ff88)  // Healthy
trust >= 40 → orange (#ff9800)  // Stressed
trust <  40 → red    (#ff3d3d)  // Hostile

// CHI gauge colors
score >= 70 → green  (#00ff88)
score >= 50 → cyan   (#00e5ff)
score >= 30 → orange (#ff9800)
score <  30 → red    (#ff3d3d)

// Alert severity colors
critical → #ff3d3d  |  high → #ff6b35  |  medium → #ff9800
warning  → #ffca28  |  info → #00e5ff