Skip to content

firmwired/neurotics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spiking Neural Network (SNN) for Autonomous Navigation

Overview

This project implements a biologically plausible Spiking Neural Network (SNN) based on the Izhikevich Model to control an autonomous agent. Unlike traditional Deep Learning models that rely on continuous value propagation, this system utilizes discrete temporal spikes to navigate complex environments.

The project was developed with a "Complexity Science" mindset, focusing on how simple neural rules (lateral inhibition, adaptation) lead to emergent navigation behaviors in non-convex obstacle fields.

Getting Started

Prerequisites

Python 3.x

C Compiler (gcc or clang)

Libraries: pygame, numpy, matplotlib, opencv-python

  1. Compile the Neural Engine

The brain is written in C for performance. You must compile it as a shared library so Python can access the neurons:

On Linux/macOS:

gcc -shared -o libbrain.so -fPIC src/brain.c

On Windows:

gcc -shared -o libbrain.dll src/brain.c

  1. Run the Simulation

Execute the main entry point to start the agent:

python main.py

What to Expect

When you run the simulation, a window will open showing the agent in a stochastic environment:

Cyan Square: The autonomous agent.

Green Square: The target goal.

Red Blocks: Physical obstacles.

Dynamic Rays: You will see lines projecting from the car. Green indicates a clear path; red indicates that the sensory neurons are detecting "fear" (proximity to an object).

Neural Indicators: The circles in the top-left corner represent the real-time firing of the motor neurons. If they flash yellow, that specific neuron has reached the $+30mV$ threshold and triggered a movement.

Controls: * Press 'R' to reset the environment with a new random configuration.

Close the window to trigger the data analysis phase.

How to Analyze the Results

Once the simulation ends (either by reaching the goal, crashing, or closing the window), the system automatically generates a report:

simulation_analysis.png:

Trajectory Plot: Shows the physical path taken. Look for "smooth" curves—this indicates the lateral inhibition is working correctly.

Sensor Input: Maps the "Risk" perceived by the neurons over time.

Spike Raster Plot: This is the most important research tool. It shows the exact millisecond each motor neuron fired. Dense clusters indicate "decisive" movement, while sparse dots indicate the agent is "thinking" or inhibited.

record.mp4:

Review the video to identify specific moments where the agent encountered a "Local Minimum." This is crucial for your research paper to explain why the 30% failure rate occurs.

The Architecture

The system is built on a C-Python Bridge, leveraging the speed of C for neural integration and the flexibility of Python for the physical simulation.

Neural Layering (12 Neurons):

Sensory Layer (8 Neurons): * Obstacle Sensors (4): Detect spatial proximity to walls.

Goal Sensors (4): Encode the vector toward the target.

Parameters: $d=2.0$ (High stability for consistent perception).

Motor Layer (4 Neurons): * Triggers Up, Down, Left, and Right movement commands.

Parameters: $d=4.0$ (Spike-frequency adaptation to prevent "greedy" locking).

Project Structure

main.py: The Python simulation environment (Pygame + OpenCV + Data Recording).

bridge.py: The interface between Python and the compiled C library.

brain.c: The core SNN logic and lateral inhibition implementation.

izhikevich.c: The mathematical engine for neural dynamics.

paper.tex: A formal LaTeX summary of findings and methodology.

About

This project explores why bio-inspired SNN designs are better than conventional algorithms.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors