03 · SPIKING NEURAL NETWORKS · PYGAME

COMPLETE · REWARD-TRAINED

LIF Snake

MEASURED RESULT0 → 19.52 avg score

A reward-trained Snake controller built from leaky integrate-and-fire neurons, plastic synapses, and recurrent winner-take-all motor populations—without ML frameworks.

PythonPygameMatplotlibLIF neuronsR-STDP
SYSTEM VIEW / 01

A visual explanation of the system's core behavior.

Recorded trained LIF controller playing Snake with motor spike and action-value charts
FIXED-SEED EVALUATION REPLAY · SCORE 15
LIVE CONTROLLER TRACE
STEP 001
heading eastfood westfood southpath clear
left25.000 spikes
straight25.000 spikes
right48.002 spikes
SELECTED ACTIONRIGHTreward +0.08

WHAT THE NETWORK IS DOINGFood is behind-left in absolute space. The east × south context activates most strongly, so the right motor spikes twice and wins the inhibitory competition.

Observable inputs, action values, and spikes—not a generated chain-of-thought.

19.52 ± 9.85score across 40 seeds
48plastic motor synapses
45best evaluation score
01 / PROBLEM

What had to change.

Most game agents hide decision-making behind high-level ML libraries. This project asks what a controller looks like when the computation is built at the individual neuron and synapse level.

02 / BUILD

How the system works.

Eleven state features become sensory spikes. Sixteen heading × food populations feed left, straight, and right LIF motors through reward-modulated synapses; danger channels inhibit unsafe moves and recurrent competition selects one action.

03 / PROOF

Why the result holds up.

Across 40 fixed unseen seeds, the trained controller averaged 19.52 ± 9.85 food against an untrained score of zero, reached 45 on its best run, and passed 28 neuron-to-game tests.

IMPLEMENTATION NOTES

  • Reward-modulated spike-timing plasticity
  • Saved weights + fixed-seed evaluation
  • 28 neuron-to-game tests

Want the code and full documentation?

View source on GitHub