← All articles

Beyond Finite State Machines: Bringing Space RTS Opponents to Life with Contrastive Decision Models

2026-09-28 — Michael Leung

When designing a real-time strategy (RTS) game, especially a large space-themed title where players build stations, mine asteroids, and command fleets, one of the first big challenges is creating an opponent that feels smart instead of just following a script.

For years, game AI has used rule-based systems like Finite State Machines (FSM) and Behavior Trees. These methods are reliable, but they have some major weaknesses:

Recent advances in neural decision models now give us a practical way to move beyond static scripts and create more adaptive, intuitive game AI.

The Rise of Intuitive "System One" AI

Traditional Large Language Models (LLMs) generate text by predicting one token at a time. This works well for dialogue and story generation, but it is too slow for the fast control loops needed in real-time strategy games.

Because of this speed issue, there is growing interest in fast, intuitive models like Jev, as well as new research from Stanford and Nvidia on Contrastive Language Models (CLM) for real-time decisions.

Instead of generating long text explanations for each decision, a contrastive model treats decision-making as a problem of finding the best match between actions and the current situation:

  1. Game State Ingestion: The current tactical state (fleet counts, mineral yields, station health, spotted hostiles) is encoded into a high-dimensional vector representation.
  2. Action Candidate Evaluation: Available discrete actions (e.g., build_harvester, scout_sector_4, reinforce_perimeter) are embedded alongside the state.
  3. Contrastive Scoring: With contrastive loss methods like InfoNCE, the model quickly checks how well each possible action fits the current game state, all at once.

Since this system skips the slow, step-by-step text generation, it can make decisions almost instantly. Tests in real-time environments show it is much faster than standard models, so you can run neural inference right inside the game loop.

Designing an RTS Action Space

To use contrastive decision models in an indie space RTS, you need to organize the possible actions into clear, compact formats that a small neural model can understand:

[State Vector]
|-- Economy: Minerals (2,400), Plasma (350), Energy Deficit (False)
|-- Infrastructure: Space Station (Level 2), Shipyard (Active), Defense Turrets (3)
`-- Reconnaissance: Enemy Scout Detected (Sector B), Fleet Power Ratio (0.85)

[Evaluated Candidate Actions]
|-- Action A: "Construct Cruiser" -> Compatibility Score: 0.89
|-- Action B: "Expand Mineral Outpost" -> Compatibility Score: 0.42
`-- Action C: "Deploy Interceptors to Sector B" -> Compatibility Score: 0.94 (Selected)

By letting the neural model handle big-picture strategy and the game engine handle movement and actions, the game stays fast and unpredictable. Even smaller models with a few hundred million parameters can manage complex strategies on regular hardware.

Neural networks are no longer just for post-game analysis or story elements. By adding lightweight contrastive models directly into gameplay, we can create virtual commanders that watch, react, and surprise players as the game unfolds.

← All articles