Navleen Singh Thukral

← Selected projects

NEATJS: neuroevolution of augmenting topologies in JavaScript

An early implementation of NEAT, a neuroevolution algorithm that grows a neural network’s structure over generations, aimed at putting AI into the hands of web game developers.

Read the code on GitHub

My role
Sole author
Context
Personal project, work in progress
Period
2019 to 2020
Stack
Node.js, Express, socket.io, Cytoscape.js
Repository
SNavleen/NEATJS

Goal

The repository describes it as a simple implementation of Neuro Evolution of Augmenting Topologies in JavaScript, giving web game developers the ability to add AI. NEAT is the algorithm introduced by Kenneth Stanley and Risto Miikkulainen in 2002: instead of fixing a network’s shape, it evolves both the weights and the structure, starting small and adding neurons and connections only when they help.

What I built

  • A genome model: input, output and hidden neurons, and synapses with a weight, an enabled flag and an innovation id.
  • An add-connection mutation that avoids invalid links (input to input, output to output), turns backwards ones around, and reuses a shared record so the same connection always gets the same id.
  • An add-neuron mutation that splits an enabled connection: the old one is disabled and a hidden neuron is inserted with two new connections, the first with weight 1 and the second carrying the old weight, as NEAT prescribes.
  • A first pass at crossover, a species container, and a visualiser: the server sends a genome over socket.io and Cytoscape.js draws its neurons and synapses, which let me inspect crossover and mutations visually. The server route is currently commented out.

Problems I worked through

  • Innovation tracking. I iterated on how to give the same connection the same id across genomes: a global list of synapses, a trial of innovation numbers on neurons as well, and finally a shared synapse record with a counter per type. A last fix to the counters came in February 2020.
  • Copying synapses. Mutations need a copy of a shared synapse with a new weight. The commit history and comments record six ways of cloning an object in Node that I tried, ending in a dedicated clone method.

Where it stands

This is an early-stage foundation, not a finished library. The genome and mutation operators are in place, crossover is a first pass, and the species class is only a container, with no fitness evaluation or generation loop yet. The README is just a title. This describes the repository as of its latest commit, in February 2020.