Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EntLab

Place Ents (Entities) into the world, press play, and a Python file determines what happens in the next tick.

Launch EntLab in your browser

EntLab running Conway's Game of Life

Why this exists

I got interested in artificial life (alife), or the idea that a few simple rules are enough to produce something that behaves like it's alive. I wanted somewhere to actually experiment with it rather than watch someone else's finished demo. So I built the sandbox I wanted with Claude.

EntLab is short for Entity Lab. An Ent is one entity, a single cell that is either there or not. The lab part is the point of this thing: nothing is hardcoded. You can change or edit the rulesets for worlds whenever.

What you get

  • Rules you write. A ruleset is a single .py file defining step(world). Nine examples are included.
  • Drawing tools. Place, select, move, and make shapes, with brush sizes 1–10. Copy any patch and stamp it anywhere, rotating and flipping as you go.
  • Go forwards or backwards in time. Every tick is recorded, so you can step backward as well as forward at many speeds, with a reset button taking you to when you pressed play last.
  • Watch the population. A live sparkline of how many Ents exist makes booms and collapses legible. A minimap shows where you are on big boards.
  • Boards up to 2048². Vectorized rules stay comfortable at scale. Conway runs about 2 ms per tick on a 1000 × 1000 grid. Speed goes from ×0.1 to ×1000.
  • One file is a whole world. Saving writes a .grid with the ruleset's source embedded, so a world you send someone always runs. Drag it onto the window to open it.
Drawing and selection Ruleset editor
Drawing and selecting Ents Editing a Python ruleset
Population graph World creation
Inspecting the population graph Creating a new world

Conway's Life

This is a complete, working ruleset—not an excerpt:

def step(world):
    n = world.neighbor_counts()
    world.cells[:] = (n == 3) | (world.cells & (n == 2))

world.cells is a live NumPy array, so whole-grid rules stay short and fast. Per-cell get / set works too, which is how you write things that aren't cellular automata at all. The included gravity ruleset makes Ents fall and stack, and langtons_ant is a walker that keeps its own state.

Getting started

In your browser

Nothing to install. The web version isn't a lookalike—it's the same Python program compiled to WebAssembly, with the same menus, tools, and keybinds. The first visit downloads a Python runtime of about 15 MB, then it's cached.

Launch EntLab

Run from source

With Python 3.8+ from python.org, double-click Launch EntLab.pyw—no console window, and the first run installs pygame and NumPy itself. From a terminal:

python3 main.py

Create your first world

  1. Name it and size it. The grid runs from (1, 1) at the bottom-left up to whatever size you pick, 8 to 2048 cells per side. Type 200 x 150, or just 300 for a square.
  2. Pick a ruleset. This is the law of nature for the new world. conway is the classic one. tutorial is a walkthrough written as comments inside the file.
  3. Shape and edges, if you like. A world can be a rectangle, an ellipse, a diamond, or a hexagon. A rectangle's edges can be solid walls, a torus that wraps both ways, or a cylinder that wraps left to right.
  4. Create world, then draw. You start holding place, so click or drag on the board to paint Ents.
  5. Press Space. The ruleset takes over and runs ten ticks a second.

If nothing seems to happen, you probably drew something the rule holds still. Under Conway a lone Ent dies at once and a 2 × 2 block sits there forever. Try a rough diagonal smear instead.

Writing rulesets

A ruleset is one .py file holding the law of nature for a world. Whatever it does to world is the rule. There is nothing else going on behind it.

DESCRIPTION = "one line shown in the rulesets menu"  # optional

def step(world):  # required name, required single argument
    ...           # advance the world by exactly one tick

EntLab calls step(world) once per tick while playing, and once per press of N. Rules can use:

  • world.cells for fast NumPy operations across the full grid
  • world.get(...) and world.set(...) for cell-by-cell behavior
  • world.rng for reproducible randomness
  • world.state for JSON-serializable memory between ticks
  • world.neighbor_counts() for cellular-automaton rules

Start with the tutorial. Select the tutorial ruleset in Customize rulesets, create a world, then open rulesets/tutorial.py in any text editor and follow the experiments written into it. template.py is a clean file to copy, and New ruleset from template does exactly that.

Saving and sharing

Press S to save. A .grid file holds the board, the tick count, the ruleset's whole source, and any state the rule was keeping. That means a world you send someone always runs, even if they have never seen that ruleset. Drag a .grid onto the window to open it.

Because the source travels inside the file, editing a ruleset in your library never quietly changes worlds you already saved. When you do want that, use Escreload.

Included rulesets

  • tutorial
  • conway
  • replicator
  • maze
  • seeds
  • life_without_death
  • gravity
  • langtons_ant
  • template

Project status

Bug reports, ideas, and interesting rulesets are welcome in GitHub Issues.

Author

Made by Jonah Feinberg with Claude.

Releases

Contributors

Languages