random walk grid function