Skip to content

Showcase: Evolved Logic Circuits

A few dozen logic gates clear Mario 1-1, make a bug walk, and make a snake swim.

Nothing on this page learned neural-network weights. Each controller is a circuit of two-input logic gates (AND, OR, XOR, …), grown generation by generation with neuroevolution (NEAT). The circuits stay small, yet they find their own way to beat a game or move a body.

  • Screen and sensor values are converted into bit vectors and fed into a logic-gate circuit
  • The circuit’s output bits pick an action such as “run right”, “jump”, or “bend this joint”
  • NEAT changes the shape of the circuit itself (which gates exist and how they are wired) every generation and keeps the individuals that do well

What remains after evolution is not a weight table but a logic circuit small enough to read. For several environments you can follow it all the way down to a circuit diagram and Boolean formulas. The mechanics are in How It Works.

Press play to watch (muted, looping). The gate count is the size of the circuit evolution found.

Super Mario 1-1Clears the stage while looking only at terrain and enemy positions.32 gates (12 after shrinking)
Bug walkerA two-legged bug starts walking after 4 generations and 22 seconds of evolution.32 gates
Snake-like swimmerMoves through water by sending a wave down its body.37 gates
HalfCheetah gallopRuns by switching between only 2 of 64 possible moves.3 logic terms decide the switch
Bipedal walking (BipedalWalker)Walks forward even after continuous torques are reduced to on/off.48 two-input LUTs
Flappy BirdKeeps deciding whether it fits through the gap in the pipes.11 gates
2D race carCompletes a lap using 7 distance sensors.22-23 gates
Snake gameCollects food from just 11 bits of surroundings.12-14 gates
CartPoleMoves the cart to keep the pole upright.8 gates

Logic circuits do not always win. With the same observations and the same evaluation, we compared them against classic NEAT with real-valued weights (NN). The winner depends on the environment.

EnvironmentLogic circuit (DLGN)NNOutcome
Flappy BirdSolved in 2 of 2 runs with 11 gatesNot solved even after 900 generationsLogic circuit wins
2D race carSolved in 2 of 2 runs with 22-23 gatesNot solved in either runLogic circuit wins
Super Mario 1-11 of 2 runs cleared (32 gates)1 of 2 runs cleared (51 parameters)Tie
Bug walkerWalks with 32 gates (distance 20.6)Walks with 16 parameters (21.1)About even
CartPoleSolved immediately with 8 gatesSolved immediately with 4 parametersTie
LunarLanderFailed independent verificationLands with 12-33 parametersNN wins

Gate counts and parameter counts are different units, so they cannot be divided into a ratio. Detailed comparisons, including where the circuits lost, are in Creatures & Robots and Games & Control.

  • Super Mario: the 32-gate clearing circuit, and why it is closer to memorization
  • Creatures & Robots: bug, snake, cheetah, biped, quadruped, humanoid
  • Games & Control: race car, Flappy Bird, Snake, CartPole, LunarLander, robot arms
  • How It Works: how NEAT and logic-gate circuits fit together