# Arachne: An Experiment in Digital Instinct

**Arachne** /əˈræk.ni/ brings a digital creature to life. It is not a standard game character: it is a biological simulation driven by a **Spiking Neural Network (SNN)**. This project explores the boundary between code and instinct. It demonstrates how raw sensory data transforms into movement through a web of artificial neurons.

![Simulation View](preview.png)

<video src="peek.mp4" controls title="Demo Video"></video>

## The Anatomy of a Hunter

The simulation centers on a spider called Arachne. It does not follow scripted paths. It hunts using a sophisticated nervous system. The creature possesses a multi-faceted visual system: different "eyes" cover specific angles and ranges to detect prey.

Vision is not its only sense. The spider feels the world through its legs. Specialized vibration sensors detect the movement of flies nearby. These sensory inputs flow directly into the neural network, they stimulate specific neurons based on proximity and angle. The output is not just data, it is an action. Motor units fire to rotate the body, move forward, or freeze in response to stimuli.

## The Neuromorphic Brain

The core of this project is the **NervousSystem** class. It mimics biological processing using a **Leaky Integrate-and-Fire (LIF)** model. Neurons in this system do not pass continuous numbers like deep learning models. Instead: they accumulate an electric charge over time.

This charge decays if no input is received: this mimics biological recovery. When the potential hits a critical threshold: the neuron "spikes". It fires a single discrete signal to its neighbors. Excitatory synapses increase the charge of target neurons, while inhibitory synapses suppress them. This creates a complex dynamic where behavior emerges from the timing of these spikes.

## Simulation vs. Reality

This project pushes the limits of standard computing to mimic biology. However, it remains an approximation. A true biological brain operates asynchronously in continuous time. Arachne currently lives within a synchronous loop: its nervous system updates in lockstep with the 60 FPS frame rate.

The current network is also static. The synaptic weights are hardcoded to define behavior: the spider is born with its instincts already formed. It does not yet learn from its failures.

## The Path Forward

The evolution of Arachne is just beginning. The next major step is to break free from the frame rate. I plan to implement an **Event-Based Neural Engine**. This will allow neurons to fire asynchronously via a priority queue, which will create true time independence.

I also aim to introduce plasticity. By implementing **STDP (Spike-Timing-Dependent Plasticity)** the spider will gain the ability to learn. It will strengthen connections that lead to a successful catch. The simulation will eventually support complex morphology and interaction with dangerous environments.

## Technical Foundation

* **Language**: C++17 
* **Engine**: raylib 
* **Structure**: Simple Makefile system

## License

MIT