This MATLAB script takes the 2D random walk algorithim and adds two more direction possiblity to it so it can be applied in 3D to simulate gas diffusion in some box.
The algoritim is similar to that of the 2D Random Walker simulation (link: https://github.com/nawaf97k/Cream-in-Your-Coffee-Problem-Simulation), only in 3D.
This script plots in realtime as the algoritim is being iterated.
Reference Used: Computational Physics 2nd Edition - Nicholas J. Giordano and Hisao Nakanishi