gitwtfhub

wtf is lifejs?

karpathy/lifejs — explained in plain English

Analysis updated 2026-07-17 · repo last pushed 2012-05-27

117JavaScriptAudience · generalComplexity · 2/5DormantSetup · easy

TL;DR

A browser-based artificial life simulator where simple virtual creatures move, eat, reproduce, and evolve in real time, demonstrating natural selection through emergent behavior.

Mindmap

mindmap
  root((repo))
    What it does
      Artificial life sim
      Creatures evolve
      Runs in browser
    Tech Stack
      JavaScript
      Sylvester math lib
      Canvas
    Use Cases
      Teach natural selection
      Tweak parameters
      NPC behavior ideas
    Audience
      Educators
      Hobbyists
      Game developers
    Origin
      Port of Scriptbots

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Watch virtual creatures evolve survival strategies in real time to teach natural selection without a biology lecture

REASON 2

Tweak mutation rate, creature speed, and food availability to see how the virtual ecosystem's behavior changes

REASON 3

Use the creature AI and canvas simulation as a starting point for NPC behavior in a browser game

What's in the stack?

JavaScriptSylvester.jsCanvas

How it stacks up

karpathy/lifejskunchenguid/lavish-axifastify/fastify-schedule
Stars117118119
LanguageJavaScriptJavaScriptJavaScript
Last pushed2012-05-272026-07-01
MaintenanceDormantActive
Setup difficultyeasyeasyeasy
Complexity2/51/52/5
Audiencegeneraldeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Runs directly in the browser, a JavaScript port of the older Scriptbots project.

Wtf does this do

This is a JavaScript-based artificial life simulator that runs directly in your web browser. It creates a digital world where simple virtual creatures evolve and compete over time, similar to how real organisms adapt in nature. You can watch them move around, eat food, reproduce, and struggle for survival on your screen in real time. The simulator works by spawning creatures into a canvas environment (the visual area where the action happens). Each creature has basic behaviors and can sense its surroundings, things like whether food is nearby or if another creature is close. They can move, eat, and breed, and their offspring inherit traits from their parents but with slight random variations. Over many generations, you'll see the creatures get better at surviving in their particular environment, developing strategies like clustering near food sources or avoiding predators. The whole thing is powered by Sylvester, a math library that handles the physics and calculations running behind the scenes. Who would find this useful? Game developers, educators, and curious programmers interested in evolution and AI. Teachers could use it to demonstrate how natural selection works without needing to explain complex biology, students can just watch the creatures adapt in real time. Hobbyists fascinated by artificial intelligence and emergent behavior might enjoy tweaking the parameters to see how different rules create wildly different outcomes. Someone building a game with NPC behavior or exploring what happens when you simulate life under different constraints could also use this as a starting point or inspiration. The main thing to know is that this is a port of an older project called Scriptbots, translated from another language into JavaScript so it can run on the web. You can customize how the simulation works by adjusting various settings, the README points to a list of tweakable parameters if you want to experiment with changing mutation rates, creature speed, or food availability to see how the virtual ecosystem responds.

Yoink these prompts

Prompt 1
Using karpathy/lifejs, change the mutation rate parameter and describe how the creature population's behavior changes over 50 generations.
Prompt 2
Show me how the creature sensing logic works in lifejs so I can add a new sense, like detecting predators from further away.
Prompt 3
Using lifejs as a base, help me adapt the creature movement and reproduction code into NPC behavior for a browser game.
Prompt 4
Explain how lifejs uses the Sylvester math library to calculate creature movement and collisions.

Frequently asked questions

wtf is lifejs?

A browser-based artificial life simulator where simple virtual creatures move, eat, reproduce, and evolve in real time, demonstrating natural selection through emergent behavior.

What language is lifejs written in?

Mainly JavaScript. The stack also includes JavaScript, Sylvester.js, Canvas.

Is lifejs actively maintained?

Dormant — no commits in 2+ years (last push 2012-05-27).

How hard is lifejs to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is lifejs for?

Mainly general.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.