Fernando Guzman

October 2025 · Python, Flask · Code on GitHub

Emergent Behavior Sim

A Tron-style bot for the Case Closed datathon. It plays on a wrap-around grid and wins with layered spatial heuristics, no machine learning.

End of a match on the neon grid, with UltraHeuristicAgent declared the winner
End of a match: UltraHeuristicAgent outlasts its opponent.

The game

Two players move around an 18×20 board whose edges wrap around, each leaving a permanent trail. Touch any trail and you're out. Head-on collisions go to the longer trail, and each player gets three boosts that allow a double move. A match lasts 500 turns or until someone crashes. My agent, UltraHeuristicAgent, runs as a Flask service that the judge engine asks for a move every turn.

The project name comes from how it plays. There's no trained model, just a handful of local rules about space, distance, and risk, but together they produce something that looks like strategy: expanding, pressuring, and sealing the opponent off.

Controlling space

Every move is scored by score_move(), mostly on how much space it leaves me:

In a Tron endgame, whoever controls more area usually wins, so that comes first and everything else adjusts it.

Trapping

The bot also models the opponent. evaluate_trap() estimates how much the opponent's space shrinks if I move into a given cell. evaluate_self_trap_potential() and should_self_trap() handle a move that sounds backwards: sealing myself into a region on purpose. That only makes sense when I'm more than 15% ahead on space and more than 5 cells from the opponent, and then it turns a space lead into a guaranteed win.

Pressure and lookahead

Openings, boosts, and fallbacks

It opens with a short book of safe seven-move expansions for the two known spawn points, then hands off to the heuristics. Boosts are spent by rule:

If scoring ever comes up empty, efficient_path_move() falls back to wall-following (right-hand rule, preferring paths with at least two safe cells ahead).

The bot keeps a running state (space advantage, danger, move history) and changes phase on its own.
phaseturnsbehavior
Early< 40Grab territory; opening book for known spawns
Midgame40–220Balance expanding and trapping; boost if behind >25%
Endgame> 220Limit the opponent's options; boost when in danger

Running it

Everything is Python behind a Flask server with the endpoints the judge expects (take the game state, return a direction, optionally with :BOOST). The repo includes a local judge and a sample opponent for practice matches, a compliance tester, and a Docker image for the competition sandbox (CPU only, under 5 GB).

Back to projects