PINONITE/NIKOLAS PINON ← CREATIVE SYSTEMS
PINONITE · FIELD NOTES · CREATIVE SYSTEMS
PUBLISHEDAugust 10, 2026

PERSONAL PROJECT · BUILT AFTER HOURS

Machine learning CREATIVE SYSTEMS ↗

Neuroevolution for a self-driving car: learning happens between runs

An interactive self-driving car simulation using ray sensors, a threshold neural network, neuroevolution, diverse populations, and an editable fitness function.

The most important correction to make about this experiment is in the title: the car does not update its network while it drives. There is no backpropagation, reward gradient, or online reinforcement step. The browser creates a population of networks, mutates their weights and biases, and scores what happens when the cars meet the same traffic.

That is still a useful machine-learning toy. It becomes more useful when the mechanism is named precisely.

The complete demo puts road physics, sensors, network activations, a population, traffic, persistence, and fitness controls on one screen. That is useful after the pieces have names. Here they arrive one boundary at a time: geometry becomes a number, numbers become switches, switches become a drive, and a score decides what survives.

Sensing is geometry

The default car casts five rays across a ninety-degree spread. Every ray is tested against road-border segments and every polygon edge in traffic. When several intersections exist, the closest offset wins.

A missing hit becomes 0. A detected obstacle becomes 1 - offset, so a nearer obstacle produces a stronger input. This small normalization layer turns drawing geometry into numbers the network can consume.

LIVE MODEL / car rays

A ray becomes a number

INTERACTIVE
WORLD SO FAR
  1. A ray becomes a number +
QUESTION How does a line in front of the car become one useful sensor value?
COMPARE TWO CONDITIONS
WATCH FOR

Drag traffic through the sensor fan. Only the nearest hit counts, and moving it closer should increase the proximity value.

YOUR TURNCompare condition A with B, then inspect what changed.
DRAG TRAFFIC THROUGH THE SENSOR FAN
SENSOR REACH 100 PX OBSTACLE OFFSET 86% ACROSS ROAD
Accessible experiment transcript

One ray tests road and traffic segments; only the nearest valid intersection becomes its normalized proximity input. Canvas gesture: drag traffic through the sensor fan.

Drag traffic through the sensor fan. Each ray may cross several segments, but only the nearest valid intersection becomes its proximity input.

The sensor is not “vision.” It is a designed interface to the environment. Changing its count, reach, or angle changes what the network can distinguish before learning enters the discussion. Garage edits are staged until the next run: rays keep stable IDs, so existing inputs retain their learned weights while a new ray starts with one new row of random weights.

The geometry now produces useful measurements, but the car still behaves exactly as before. Five numbers do not choose left, right, forward, or reverse. The next missing piece is a policy that can turn perception into an action.

CONTROL LOOP / SENSE DECIDE ACT

The driving policy is a closed sensory loop

FOLLOW THE ARROWS
01 · Five rays

Each sensor ray finds its closest road-border or traffic intersection.

Accessible diagram transcript

Five sensor rays become proximity inputs, pass through a threshold network, drive four controls, and update the next sensory frame.

Select each stage to follow road geometry into proximity inputs, threshold decisions, vehicle controls, and the next sensor frame.

The network is intentionally small

The default Car creates a 5 → 6 → 4 network, but the input layer now follows the sensor array. Each level computes a weighted sum and compares it with a bias. The result is binary.

LIVE MODEL / car threshold

A number becomes a switch

INTERACTIVE
WORLD SO FAR
  1. A ray becomes a number ✓
  2. A number becomes a switch +
QUESTION When should a continuous sensor value turn a control node on?
COMPARE TWO CONDITIONS
WATCH FOR

Drag the input handle across the red threshold mark. The output should switch exactly once at the boundary.

YOUR TURNCompare condition A with B, then inspect what changed.
DRAG THE INPUT HANDLE ACROSS THE THRESHOLD
INPUT PROXIMITY 0.30 NODE BIAS -0.25
Accessible experiment transcript

A weighted sensor input and bias cross a hard threshold, turning a continuous measurement into a binary driving decision. Canvas gesture: drag the input handle across the threshold.

Drag the normalized sensor input across the fixed threshold. The output changes only when the weighted sum crosses that boundary.
MODEL / WALKTHROUGHThreshold policy node
oj=Hi wjixi + bj)

Turn several sensor readings into one yes-or-no control decision.

  1. 01
    Read every sensorEach x is one input, such as the distance reported by a ray.
  2. 02
    Weight the evidenceEach w decides how strongly that sensor should influence this output node.
  3. 03
    Add a biasThe bias shifts how much combined evidence the node needs before it activates.
  4. 04
    Cross the thresholdH converts the total into an on or off output: steer, accelerate, or reverse.
The network is feed-forward and binary: a Heaviside step turns each weighted sum into an on/off decision.

Those four outputs map directly to forward, left, right, and reverse controls. Vehicle code then applies an adjustable acceleration factor, coasting drag, explicit reverse braking, a hard speed limit, steering direction, polygon collision, and damage state. Releasing forward preserves momentum; reverse is the deliberate brake before it becomes reverse thrust. The network chooses switches; ordinary simulation logic determines what those switches do.

This division is worth preserving. The policy should not need to rediscover basic vehicle physics or collision geometry from pixels.

The car can now sense and act, which makes the next problem impossible to ignore: a randomly initialized policy is terrible. It may steer into a border, hold forward forever, or freeze behind traffic. One policy is a demonstration, not a search.

One policy becomes a population

Copy the same small network many times and perturb its weights and biases. Give every candidate the same traffic seed so differences in the result come from policy, not from one car receiving an easier road.

LIVE MODEL / car population

Variation creates candidates

INTERACTIVE
WORLD SO FAR
  1. A ray becomes a number ✓
  2. A number becomes a switch ✓
  3. Variation creates candidates +
QUESTION Why test a population instead of trusting one randomly initialized policy?
COMPARE TWO CONDITIONS
WATCH FOR

Drag the mutation handle while the cars run. Their traffic stays fixed while their policy paths spread farther apart.

YOUR TURNCompare condition A with B, then inspect what changed.
DRAG TO WIDEN OR TIGHTEN MUTATION
MUTATION RANGE 17% CANDIDATES 8 CARS
Accessible experiment transcript

A parent threshold policy branches into nearby mutations; every candidate sees the same traffic so behavior can be compared. Canvas gesture: drag to widen or tighten mutation.

Drag the mutation handle while the cars run on the same road and traffic. Their policy paths spread apart, but the simulation still needs a defensible way to decide which behavior deserves another generation.

Variation gives the experiment options. It does not tell us which option is better. A population without an objective is only a collection of differently bad drivers.

Selection happens between generations

The application generates a population of cars. The best brain is checkpointed automatically in local storage after every completed run; the next population starts from that saved champion, and all but the first car receive a mutation. Every generation receives a fresh randomized traffic seed, while every candidate inside that generation sees the same layout. That keeps comparisons fair without teaching the population one permanent obstacle pattern.

The old version treated furthest-forward position as the whole objective. That rewarded survival, but it also let a cautious car settle behind traffic. The current score combines forward progress, average pace, overtakes, close-following time, idle time, and collision state—and the Fitness ledger makes each value editable. A Smart run extends only when the champion sustains pace, changes lanes, passes traffic, and avoids tailing or collision; moving straight ahead is not enough. Strong saved fitness also unlocks curved roads, then traffic that changes lanes.

LIVE MODEL / car fitness

The reward ledger changes the winner

INTERACTIVE
WORLD SO FAR
  1. A ray becomes a number ✓
  2. A number becomes a switch ✓
  3. Variation creates candidates ✓
  4. A score chooses what survives +
QUESTION Can the same three drives produce different winners under different values?
COMPARE TWO CONDITIONS
WATCH FOR

Drag the reward target across the field. The same three drives should reorder as passing reward and collision cost change.

YOUR TURNCompare condition A with B, then inspect what changed.
DRAG THE REWARD TARGET; WATCH THE RANKING
PASSING REWARD +18 COLLISION PENALTY −25
Accessible experiment transcript

The same three candidate drives receive different rankings when passing reward and collision penalty change. Canvas gesture: drag the reward target; watch the ranking.

The three drives are unchanged. Drag the reward target to change passing reward and collision cost, then watch the ranking change with it.
MODEL / WALKTHROUGHComposite driving fitness
F=wpΔy + wvv̄ + woNpasswcIcollisionwiTidle

Score a complete drive by rewarding useful progress and charging for failure modes.

  1. 01
    Reward forward progressDistance advanced is the largest proof that the car is solving the road.
  2. 02
    Reward useful paceAverage speed distinguishes confident motion from barely creeping forward.
  3. 03
    Reward overtakesPassing traffic gives the policy a reason not to trail a safe car forever.
  4. 04
    Subtract failuresCollisions and idle time reduce the score. Each weight controls how expensive that behavior is.
Progress, pace, passing, collision, and idling are visible terms with editable weights. Changing them changes the behavior selected for mutation.

Now the loop can preserve a candidate and mutate around it. That closes the first evolutionary cycle—and opens a more interesting gap. The score can be internally consistent while rewarding the wrong behavior. A car that safely trails traffic may beat a risky overtaker; a large passing bonus may produce reckless weaving.

SEARCH / MUTATION LOOP

Search is scored population mutation

FOLLOW THE ARROWS
01 · Elite brain

The best-scoring network becomes the seed; manual save can persist it between visits.

Accessible diagram transcript

An elite network seeds a population, mutations create variants, identical traffic tests each policy, and composite fitness selects the next elite.

The loop is evolutionary, not gradient training. Composite fitness selects and checkpoints the next elite between runs.

Preserve several kinds of success

One champion is simple, but it narrows the search. A fast overtaker, a cautious lane changer, and a car that recovers well from dense traffic may encode useful but incompatible behaviors. Replacing all three with the single highest score makes the next generation vulnerable to one lucky traffic layout and encourages the population to collapse around one strategy.

The next version should preserve a small, diverse elite set. Selection could keep the top scorer plus candidates separated by behavioral descriptors such as pace, passes, lane-change frequency, following time, and survival. Mutations would then branch from several proven strategies instead of one. The question changes from “which car won?” to “which distinct ways of driving are worth exploring further?”

Treat the reward ledger as a hypothesis

The score is not an objective truth about good driving. It is a compact statement of what this experiment values. Increasing the passing bonus may produce decisive overtaking or reckless weaving. Raising the collision penalty may improve safety or reward a car that never challenges traffic. Even a pace reward can accidentally favor sustained forward motion over useful positioning.

A useful comparison should run the same saved elites and traffic seeds against several named ledgers, then compare progress, passes, survival, tailing, and behavioral diversity separately. That would show whether an apparent improvement survives a change in incentives—or exists only because one coefficient made the chart look better.

Compare switches with continuous control

The current network emits four binary decisions: forward, left, right, and reverse are either on or off. Vehicle physics softens those switches with acceleration, coasting, braking, and a speed limit, but steering still begins with a threshold crossing. That makes the policy easy to inspect while encouraging abrupt corrections near a decision boundary.

A continuous-output policy would instead emit steering and throttle values across a range. The comparison should keep sensors, traffic seeds, fitness terms, and population budget fixed. Then the interesting evidence is not just final score: it is steering smoothness, recovery time, lane stability, overtaking behavior, and whether the more expressive controller becomes harder to evolve or explain.

What the result does and does not show

The source repository demonstrates ray casting, segment intersection, polygon collision, a feed-forward threshold network, mutation, local persistence, seeded traffic, fitness design, and a network visualizer. It does not establish a robust autonomous-driving model. Traffic is synthetic, the objective is hand-designed, and the population is evaluated in a simplified browser world.

The experiment is useful because perception, policy, physics, selection, and visualization are small enough to inspect together. With those boundaries visible, “learning” stops being a glow around the system and becomes a sequence of concrete choices.

Put the pieces together

The complete source lab now arrives after the mechanism. These views share one evolving population and saved history. Garage edits the input topology while paused; Network exposes live activations; Fitness compares the current run with ghosted generations and makes the reward ledger editable.

SESSION 01 / 03

Build the sensing field

BUILD / PAUSED
Add, aim, resize, or remove rays. Stable sensor IDs keep learned weights; a new ray begins with newborn weights when the next generation starts.
SESSION 02 / 03

Watch measurements become decisions

SAME RUN / LIVE
The shared population resumes here. Live edges connect the road’s five proximity inputs to the network’s four control switches.
SESSION 03 / 03

Read selection as evidence

SAME RUN / LIVE
Current lines restart on the x-axis while older generations remain as fading area traces. Adjust the ledger and promotion policy without leaving the shared run.