A simple Python simulation of Self-Avoiding Random Walks in 2D. This project simulates multiple walkers that move randomly on a grid without revisiting previously visited positions and visualizes the paths using matplotlib
and i have shown some results in the results folder, they are bad because i am bad at matplotlib, but at least they work. Thanks for checking out this project.
A self-avoiding walk (SAW) is a sequence of moves on a grid where no position is visited more than once. SAWs are important in statistical physics, especially in modeling polymers.
- uses a list to store position of each walker, the nodes he has visited, and the edges he has used.
- This list is updated each time he visits a new node, and the new node is selected randomly among the non visited nodes which are at a horizontal or vertical distance of 1 unit from the previous node.
- In case, no new node can be selected, the program re runs itself, and a bool is used to store this condition.
- The trajectory of each node is stored in results folder.
- Simulates multiple independent walkers
- Ensures self-avoiding behavior using Python sets
- Visualizes the walks using
matplotlib
- Lightweight: no dependencies beyond the standard library and
matplotlib
- Uses Monte Carlo method.
- Clone this repository:
git clone https://github.com/easrai/self-avoiding-walk.git cd self-avoiding-walk