The chess and squad AI systems running

System and tool

Three AI Systems

Building these outside an engine meant writing the parts Unreal normally hands you, which is the fastest way to learn what those parts are actually doing.

Role
AI Systems Programming
When
January 2024 to March 2024 (9 weeks)
Engine
C++ from scratch
  • C++
  • Minimax
  • Bitboards
  • Utility AI
  • Task Planning
  • 3Independent systems
  • 9Weeks

Three separate AI systems, built in C++ over a nine week module. No engine, which meant rendering, input and timing were mine to write as well. That is the part that taught the most.

Chess

Board state is held in bitboards, one 64 bit integer per piece type per colour. Move generation becomes bit manipulation rather than iteration, which is what makes searching deeply enough to play well affordable.

Search is minimax with alpha-beta pruning. The evaluation function scores material, piece position, king safety, pawn structure and mobility. Pruning only helps if you examine promising moves first, so move ordering uses most valuable victim, least valuable attacker for captures and prioritises central control otherwise. Getting the ordering right mattered more to playing strength than any single evaluation term did.

Squad coordination

A group of agents deciding independently what to do, using utility scoring across four options: pursue the player, search an area, assist an ally, or patrol. Each agent scores all four against what it currently knows and picks the highest.

What makes them a squad rather than four individuals is message passing. An agent that sees the player broadcasts it. An agent under pressure calls for help. Because assisting an ally is one of the scored options, a distress call changes the utility landscape for everyone in range, and the group converges without anything coordinating it centrally.

The cooperative behaviour is emergent, which is the appeal and also the difficulty. You tune the weights, not the outcome.

Long-term planning

A resource management game where workers collect resources and construct buildings. The planner allocates tasks by resource availability and worker proximity, so workers organise themselves rather than waiting to be told.

The supporting work is what made it a real project: collision detection for environment interaction, a countdown system for task timing, an input and rendering framework, and text metrics so the UI could lay itself out. None of that is AI, and all of it had to exist before the AI could be evaluated at all.

Breakdown

Three AI systems breakdown: the chess engine, the long-term planning game and the squad coordination map
Three AI systems breakdown: the chess engine, the long-term planning game and the squad coordination map