Random Walk Simulation in C++ ImGui

Markus Buchholz
2 min readApr 9, 2023

The random walk can be associated with the process where the agent walks randomly in a certain environment. The next step of the agent is determined by the normally distributed choice of walk direction. In two 2D spaces the agent staying in one “maze cell” can transit to the four belonging cells (right, left, up, and down). The random walk process imposes constrain regarding the agent transition which is possible if the next cell has not been visited by the agent. The walk is terminated if the agent can not transit to any other cell. All cells which are close to the actual position of the agent are visited.
Besides the certain rules of the walk which define transition conditions, the most important is the process o choosing the next step. The agent uses the random machine which generates uniformly agent directions. It means that the choice of each direction has the same probability. In C++ we apply the standard procedure which you can read about here.

The implementation of the solution I deployed in C++ with the visualization in ImGui. The introduction to the C++ ImGui and information on how to compile and build programs you will find in one of my previous articles.

The source code you will find on my GitHub.

Here is a sample of the random walk process.

Random walk process (by author)

Thank you for reading.

--

--

Markus Buchholz
Markus Buchholz

Written by Markus Buchholz

Researcher in underwater robotics

No responses yet