Knight on a chessboard

The following is an illustration of the stationary distribution of a knight moving randomly on a chessboard.

Knight Random Walk

Select a starting square and the number of steps you want the knight to move. The heatmap obtained after 10 seconds shows the fraction of visits to each of the 64 squares.

Start square: Steps:


From the same starting square as chosen above, we now move the knight for the number of steps input below and record the end square. This is repeated for the number of iterations indicated below. The fraction of iterations ending in each square is plotted. The laziness parameter helps to make the knight random walk aperiodic (but retain its stationary distribution).

Steps per run: Iterations: Laziness (0–1):

This experiment illustrates the ergodic theorem for Markov chains.