Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Artificial Worm Brain AI

An asset by leparlon
The page banner background of a mountain and forest
Artificial Worm Brain AI image holder but it is empty

Quick Information

0 ratings
Artificial Worm Brain AI icon image
leparlon
Artificial Worm Brain AI

Description WormBrain is a Godot plugin that adds a worm to your 2D scene, one whose movement is driven by a simulation of the C. elegans neural connectome. C. elegans is a tiny nematode whose complete neural wiring has been mapped and published: 302 neurons, roughly 4,000 synaptic connections. WormBrain uses that wiring to decide how the worm moves: where it steers, when it speeds up, when it reverses. The result is something that navigates, forages, and reacts, not because it was scripted to, but because the network says so. It is closer to a playground than a simulation. Based on https://github.com/heyseth/worm-sim by Seth Miller. --- Quick Start 1. Copy addons/worm_brain_plugin into your project's addons folder. 2. Enable the plugin under Project → Project Settings → Plugins. 3. Add a WormNode to any 2D scene and run the project. Explore the Inspector to customize the worm's body shape, sensors, speed, and hunger behavior. The node also emits signals you can listen to: food detection, nose touch, hunger state so your own code can react to what the worm experiences. --- Notes / Limitations - Collision is advisory. When the worm touches an Area2D, it receives a neural signal, but there is no hard physics boundary. If the neural output says keep going, it will. To contain the worm inside your level, set limiting_area in the Inspector (default: Rect2(50, 50, 1000, 1000)). - Eating. The worm eats any Area2D belonging to the worm_food group when it overlaps it. Removing the eaten food from the scene is handled by your code. - Not scientifically accurate. The connectome data is real, but the mapping from neural activity to on-screen movement involves significant simplification. This is an interactive experiment, not a research tool.

Supported Engine Version
4.2
Version String
v2.0.1
License Version
MIT
Support Level
community
Modified Date
5 days ago
Git URL
Issue URL

Worm Brain Plugin

A custom node for creating AI-powered worms in Godot Engine. brain.gd and weights.gd use real mapping taken from a C. elegans worm brain (it has only 302 neurons), enabling you to simulate it in your game. Heavily based on this project: Simulate the C. elegans worm brain on your browser.

Drag WormNode to your scene and enjoy.
Note: Does not handle collision well, so you need to limit where it can go using an editor property.

Features

  • Customizable worm behavior and segments
  • Dynamic segment creation
  • Real worm brain simulation

Installation

  1. Download the plugin from the Godot Asset Library or clone the repository.
  2. Copy the addons/worm_ai_plugin folder into your project's addons directory (if not done automatically by Godot).
  3. Enable the plugin in Project > Project Settings > Plugins.

Quick Usage

  1. Add the WormNode to your scene.
  2. Customize the worm's properties in the inspector.
  3. The worm will "collide" with any Area2D, and will eat any that is part of the group worm_food.
  4. This worm is stubborn, so a wall is a mere suggestion to it. If you want to contain the worm, make sure to decrease the limiting rect in the inspector.

Worm parameters

limitingArea # Global area where the worm can move
segment_count = 20
segment_distance = 10 
max_scale = 1.0 # The maximum scale of the worm's girth
min_scale = 0.3 # The minimum scale of the worm's girth
front_rate = 0.2 # Rate of girth increase at the front
back_rate = 0.4 # Rate of girth decrease at the back

hungry_worm = true
time_until_hungry_again = 2
time_scaling_factor = 1.0

wormBrainDelay = 0.0 # Controls the simulation speed

Communicating with the Brain

For these that want to play with the plugin code

worm.gd controls the interface of the brain with the game world. brain.gd powers the brain using the weights configured in weights.gd.
You can stimulate neurons with specific functions by enabling and disabling some flags on the brain, causing these neurons to be continuously stimulated while on:

stimulateHungerNeurons
stimulateNoseTouchNeuronsLeft
stimulateNoseTouchNeuronsRight
stimulateFoodSenseNeuronsLeft
stimulateFoodSenseNeuronsRight
stimulatePheromonSenseNeuronsLeft
stimulatePheromonSenseNeuronsRight
stimulateChemicalsSenseNeuronsRight
stimulateChemicalsSenseNeuronsLeft
stimulateTemperatureSenseNeuronsRight
stimulateTemperatureSenseNeuronsLeft
stimulateOdorRepelantSenseNeuronsRight
stimulateOdorRepelantSenseNeuronsLeft

The worm has 4 sensors (CollisionArea2D), 2 for each side. They all are part of the same sensor group; the worm knows to ignore these.
2 big ones represent smell sense, and 2 others represent touch. Collisions with these sensors activate the corresponding neurons.

License

This project is licensed under the MIT License.

Acknowledgements

This project is heavily based (it is basically a port to Godot) on the worm-sim made by Seth Miller.
Huge thanks to him for sharing that online.

Description

WormBrain is a Godot plugin that adds a worm to your 2D scene, one whose movement is driven by a simulation of the C.
elegans neural connectome. C. elegans is a tiny nematode whose complete neural wiring has been mapped and published:
302 neurons, roughly 4,000 synaptic connections. WormBrain uses that wiring to decide how the worm moves: where it
steers, when it speeds up, when it reverses.

The result is something that navigates, forages, and reacts, not because it was scripted to, but because the network
says so. It is closer to a playground than a simulation.

Based on https://github.com/heyseth/worm-sim by Seth Miller.

---
Quick Start

1. Copy addons/worm_brain_plugin into your project's addons folder.
2. Enable the plugin under Project → Project Settings → Plugins.
3. Add a WormNode to any 2D scene and run the project.

Explore the Inspector to customize the worm's body shape, sensors, speed, and hunger behavior. The node also emits
signals you can listen to: food detection, nose touch, hunger state so your own code can react to what the worm
experiences.

---
Notes / Limitations

- Collision is advisory. When the worm touches an Area2D, it receives a neural signal, but there is no hard physics
boundary. If the neural output says keep going, it will. To contain the worm inside your level, set limiting_area in
the Inspector (default: Rect2(50, 50, 1000, 1000)).
- Eating. The worm eats any Area2D belonging to the worm_food group when it overlaps it. Removing the eaten food from
the scene is handled by your code.
- Not scientifically accurate. The connectome data is real, but the mapping from neural activity to on-screen movement
involves significant simplification. This is an interactive experiment, not a research tool.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Artificial Worm Brain AI icon image
leparlon
Artificial Worm Brain AI

Description WormBrain is a Godot plugin that adds a worm to your 2D scene, one whose movement is driven by a simulation of the C. elegans neural connectome. C. elegans is a tiny nematode whose complete neural wiring has been mapped and published: 302 neurons, roughly 4,000 synaptic connections. WormBrain uses that wiring to decide how the worm moves: where it steers, when it speeds up, when it reverses. The result is something that navigates, forages, and reacts, not because it was scripted to, but because the network says so. It is closer to a playground than a simulation. Based on https://github.com/heyseth/worm-sim by Seth Miller. --- Quick Start 1. Copy addons/worm_brain_plugin into your project's addons folder. 2. Enable the plugin under Project → Project Settings → Plugins. 3. Add a WormNode to any 2D scene and run the project. Explore the Inspector to customize the worm's body shape, sensors, speed, and hunger behavior. The node also emits signals you can listen to: food detection, nose touch, hunger state so your own code can react to what the worm experiences. --- Notes / Limitations - Collision is advisory. When the worm touches an Area2D, it receives a neural signal, but there is no hard physics boundary. If the neural output says keep going, it will. To contain the worm inside your level, set limiting_area in the Inspector (default: Rect2(50, 50, 1000, 1000)). - Eating. The worm eats any Area2D belonging to the worm_food group when it overlaps it. Removing the eaten food from the scene is handled by your code. - Not scientifically accurate. The connectome data is real, but the mapping from neural activity to on-screen movement involves significant simplification. This is an interactive experiment, not a research tool.

Supported Engine Version
4.2
Version String
v2.0.1
License Version
MIT
Support Level
community
Modified Date
5 days ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers