Skip to content

Instantly share code, notes, and snippets.

@christopherphan
Created June 26, 2018 19:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save christopherphan/b0f20976258e1785c030c0d9ad92b706 to your computer and use it in GitHub Desktop.
%% 10PRINT.tex
%% Copyright 2018 Christopher L. Phan, Ph.D.
%% cphan@chrisphan.com
%%
%% Creates a random maze, inspired by
%% 10 PRINT CHR$(205.5+RND(1)); : GOTO 10,
%% by Nick Montfort, et. al., (MIT Press, 2013)
%%
%% See also:
%% https://blog.chrisphan.com/2018/05/28/10-print-in-tikz/
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% Draw background
\fill[blue!75!black] (0, 0) -- (0, 24) --
(40, 24) -- (40, 0) -- cycle;
% Draw maze
\foreach \y in {0, ..., 23}{
\foreach \x in {0, ..., 39}{
% Randomly choose a = 0 or a = 1
\pgfmathrandominteger{\a}{0}{1};
% If a = 0, then will draw SW-NE line
% If a = 1, then will draw NW-SE line
\draw[very thick, white] (\x, \y + \a)
-- (\x + 1, \y + 1 - \a);
}
}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment