- About
- Dependencies
- Running the Code
- Simulation Parameters
- Code Structure
- Resources
- Code Documentation
- License
- Want to Contribute?
This code simulates a simple neural network using Pygame library. The network consists of 25 neurons (configurable), each with a probability of being activated. The connection strengths between the neurons are randomly initialized, and they can be strengthened or weakened based on the activation patterns.
The following libraries are required to run this code:
- Pygame
- Random
- Sys
To run the code, execute the following command in the terminal:
python neuron.py
This will start the Pygame window and run the simulation.
The following parameters can be adjusted in the code to change the behavior of the simulation:
- WINDOW_SIZE: The size of the game window.
- NUM_NEURONS: The number of neurons in the network.
- INITIAL_PROBABILITY: The probability of each neuron being activated.
- MAX_CONNECTION_STRENGTH: The maximum value for the connection strengths.
- MIN_CONNECTION_STRENGTH: The minimum value for the connection strengths.
- CONNECTION_STRENGTH_DELTA: The value by which to increase or decrease the connection strength.
- PROBABILITY_THRESHOLD: The threshold for updating the neuron probabilities.
- PROBABILITY_INCREASE: The value by which to increase the neuron probabilities.
- PROBABILITY_DECREASE: The value by which to decrease the neuron probabilities.
The code is structured into the following functions:
- draw_background: Draws a background on the screen.
- draw_sparks: Draws random sparks on the screen.
- draw_connections: Draws the connections between the neurons on the screen.
- update_probabilities: Updates the probabilities of the neurons based on the activation patterns.
- mutate_connections: Mutates the connection strengths between the neurons.
- apply_external_input: Applies external input to the neurons.
- apply_feedback: Applies feedback to the neurons based on their activation patterns.
- apply_inhibition: Applies inhibition to the neurons based on their activation patterns.
- apply_synaptic_plasticity: Applies synaptic plasticity to the connections between the neurons.
- apply_learning: Applies hebbian learning to the connections between the neurons.
- apply_modulatory_signals: Applies modulatory signals to the neurons.
- apply_homeostasis: Applies homeostasis to the neurons.
- apply_refractory_period: Applies a refractory period to the neurons.
- apply_noise: Applies noise to the neurons.
- draw_activation_effect: Draws the activation effect on the screen.
The main
function contains the main loop of the game, which handles events, clears the screen, draws the connections, updates the network, and updates the screen.
This code is licensed under the MIT License.
Check out CONTRIBUTING.md
.