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.
Prerequisites
Python 3.x
C Compiler (gcc or clang)
Libraries: pygame, numpy, matplotlib, opencv-python
- 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:
gcc -shared -o libbrain.so -fPIC src/brain.c
gcc -shared -o libbrain.dll src/brain.c
- Run the Simulation
Execute the main entry point to start the agent:
python main.py
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
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:
Motor Layer (4 Neurons): * Triggers Up, Down, Left, and Right movement commands.
Parameters:
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.