summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/maze/README.md37
-rw-r--r--Master/texmf-dist/doc/latex/maze/maze.pdfbin0 -> 79265 bytes
-rw-r--r--Master/texmf-dist/doc/latex/maze/maze.tex33
-rw-r--r--Master/texmf-dist/tex/latex/maze/maze.sty87
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rw-r--r--Master/tlpkg/tlpsrc/collection-games.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/maze.tlpsrc0
7 files changed, 159 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/maze/README.md b/Master/texmf-dist/doc/latex/maze/README.md
new file mode 100644
index 00000000000..c20c91c7914
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/maze/README.md
@@ -0,0 +1,37 @@
+The maze package
+=========
+
+The maze package can generate random square mazes of a specified size.
+
+Basic Usage
+-----------
+The package only provides a user command.
+
+ \maze {⟨size⟩}[⟨seed⟩]
+
+You can read the package manual for some explanations.
+
+Copyright and License
+---------------------
+
+ Copyright (C) 2022 by Sicheng Du <siddsc@foxmail.com>
+ -----------------------------------------------------------------
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either
+ version 1.3c of this license or (at your option) any later
+ version. This version of this license is in
+ http://www.latex-project.org/lppl/lppl-1-3c.txt
+ and the latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+ and version 1.3 or later is part of all distributions of
+ LaTeX version 2005/12/01 or later.
+
+ This work has the LPPL maintenance status "maintained".
+
+ The Current Maintainer of this work is Sicheng Du.
+
+ This package consists of the files maze.tex,
+ maze.pdf,
+ maze.sty and
+ README.md (this file). \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/maze/maze.pdf b/Master/texmf-dist/doc/latex/maze/maze.pdf
new file mode 100644
index 00000000000..3f75e2a64d1
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/maze/maze.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/maze/maze.tex b/Master/texmf-dist/doc/latex/maze/maze.tex
new file mode 100644
index 00000000000..0783535bfc3
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/maze/maze.tex
@@ -0,0 +1,33 @@
+\documentclass{ltxdoc}
+\title{The \textsf{maze} package\footnote{~~This project is distributed under the \LaTeX~Project Public License, version 1.3c.}}
+\usepackage{graphicx}
+\usepackage{fontspec}
+\setmainfont{Times New Roman}
+\usepackage[misc]{ifsym}
+\author{Sicheng Du\thanks{~~\Letter~~\href{mailto:siddsc@foxmail.com}{siddsc@foxmail.com}}}
+\date{\today~~~~v1.1}
+\usepackage[colorlinks,linkcolor=purple]{hyperref}
+\usepackage{maze}
+\begin{document}
+\maketitle
+The \textsf{maze} package can generate random square mazes of a specified size. You need to start from the bottom-left corner and reach the top-right corner to play it.
+\begin{macro}{\maze}
+\marg{size}\oarg{seed} is the syntax of the command that generates a maze. Thereinto
+\begin{description}
+\item[\marg{size}] controls the density of the walls inside the maze and directly influences its complexity. It must be a positive integer greater or equal to 2.
+
+To have the package produce a satisfactory outcome, it is recommended to input a number between 20 and 30 into \marg{text}. Over large numbers may cause \TeX~to exhaust its capacity and fail to produce anything.
+\item[\oarg{seed}] is an optional parameter that specifies the seed for random numbers. If it is omitted, the current time (minute) will be used as the seed instead.
+\end{description}\end{macro}
+
+As an example, the following can be created by \cs{maze{30}[4]} and \cs{maze{20}[6]} respectively.
+\begin{figure}[h]
+\begin{minipage}{.5\textwidth}
+\maze{30}[4]
+\end{minipage}\hfill
+\begin{minipage}{.5\textwidth}
+\maze{20}[6]
+\end{minipage}
+\end{figure}
+\eject
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/maze/maze.sty b/Master/texmf-dist/tex/latex/maze/maze.sty
new file mode 100644
index 00000000000..4401fa60996
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/maze/maze.sty
@@ -0,0 +1,87 @@
+% Copyright (C) 2022 by Sicheng Du <siddsc@foxmail.com>
+% This project is distributed under the LaTeX Project Public License, version 1.3c.
+%-------------------------%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{maze}[1.1]
+\ExplSyntaxOn
+\int_new:N\l_rand
+\int_new:N\l_old \int_new:N\l_new
+\dim_const:Nn\g_size{\linewidth}
+\newcommand{\m@ze}[2]{
+ \sys_gset_rand_seed:n{#2}
+ \let\g_map\undefined
+ \let\g_walls_v\undefined\let\g_walls_h\undefined
+ \intarray_new:Nn\g_map{#1*#1}
+ \intarray_new:Nn\g_walls_v{#1*(#1-1)}
+ \intarray_new:Nn\g_walls_h{#1*(#1-1)}
+ \int_step_inline:nn{#1*#1}{
+ \intarray_gset:Nnn\g_map{##1}{##1}
+ }
+ \int_step_inline:nn{#1*(#1-1)}{
+ \intarray_gset:Nnn\g_walls_v{##1}{1}
+ \intarray_gset:Nnn\g_walls_h{##1}{1}
+ }
+ \bool_do_until:nn{
+ \int_compare_p:nNn{\intarray_item:Nn\g_map{1}}
+ ={\intarray_item:Nn\g_map{#1*#1}}
+ }{
+ \int_set:Nn\l_rand{\int_rand:n{#1*(#1-1)}}
+ \int_compare:nNnTF{0}={\intarray_item:Nn\g_walls_v{\l_rand}}{}{
+ \int_compare:nNnTF{
+ \intarray_item:Nn\g_map{\l_rand+\int_div_truncate:nn{\l_rand-1}{#1-1}}
+ }={
+ \intarray_item:Nn\g_map{
+ 1+\l_rand+\int_div_truncate:nn{\l_rand-1}{#1-1}
+ }
+ }{}{
+ \int_set:Nn\l_new{
+ \intarray_item:Nn\g_map{1+\l_rand+\int_div_truncate:nn{\l_rand-1}{#1-1}}
+ }
+ \int_set:Nn\l_old{
+ \intarray_item:Nn\g_map{\l_rand+\int_div_truncate:nn{\l_rand-1}{#1-1}}
+ }
+ \intarray_gset:Nnn\g_walls_v{\l_rand}{0}
+ \int_step_inline:nn{#1*#1}{
+ \int_compare:nNnTF{\l_old}={\intarray_item:Nn\g_map{##1}}
+ {\intarray_gset:Nnn\g_map{##1}{\l_new}}{}
+ }
+ }
+ }
+ \int_set:Nn\l_rand{\int_rand:n{#1*(#1-1)}}
+ \int_compare:nNnTF{0}={\intarray_item:Nn\g_walls_h{\l_rand}}{}{
+ \int_compare:nNnTF{\intarray_item:Nn\g_map{\l_rand}}
+ ={\intarray_item:Nn\g_map{#1+\l_rand}}{}{
+ \int_set:Nn\l_new{\intarray_item:Nn\g_map{#1+\l_rand}}
+ \int_set:Nn\l_old{\intarray_item:Nn\g_map{\l_rand}}
+ \intarray_gset:Nnn\g_walls_h{\l_rand}{0}
+ \int_step_inline:nn{#1*#1}{
+ \int_compare:nNnTF{\l_old}={\intarray_item:Nn\g_map{##1}}
+ {\intarray_gset:Nnn\g_map{##1}{\l_new}}{}
+ }
+ }
+ }
+ }
+}
+\NewDocumentCommand\maze{mO{\c_sys_minute_int}}{
+ \m@ze{#1}{#2}
+ \setlength{\unitlength}{\fp_eval:n{.4/#1}\g_size}
+ \begin{picture}(\int_eval:n{#1+2},\int_eval:n{#1+2})(-1,-1)
+ \put(0,0){\line(0,1){#1}}\put(0,0){\line(1,0){#1}}
+ \put(#1,#1){\line(0,-1){#1}}\put(#1,#1){\line(-1,0){#1}}
+ \int_step_inline:nn{#1*(#1-1)}{
+ \int_compare:nNnTF{0}={\intarray_item:Nn\g_walls_h{##1}}{}{
+ \put(
+ \int_mod:nn{##1-1}{#1},
+ \int_eval:n{1+\int_div_truncate:nn{##1-1}{#1}}
+ ){\line(1,0){1}}
+ }
+ \int_compare:nNnTF{0}={\intarray_item:Nn\g_walls_v{##1}}{}{
+ \put(
+ \int_mod:nn{##1}{#1-1},
+ \int_div_truncate:nn{##1-1}{#1-1}
+ ){\line(0,1){1}}
+ }
+ }
+ \end{picture}
+}
+\ExplSyntaxOff \ No newline at end of file
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index fc5744b90fc..83fbd6ea9e0 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -531,7 +531,7 @@ my @TLP_working = qw(
mathcommand mathcomp mathdesign mathdots mathexam
mathfam256 mathfixs mathfont mathlig mathpartir mathpazo mathpunctspace
mathsemantics mathspec mathtools matlab-prettifier mathspic maths-symbols
- matrix-skeleton mattens maybemath
+ matrix-skeleton mattens maybemath maze
mcaption mceinleger mcexam mcf2graph mcite mciteplus mcmthesis
mdframed mdputu mdsymbol mdwtools mecaso media4svg media9 medstarbeamer
meetingmins membranecomputing memdesign memexsupp
diff --git a/Master/tlpkg/tlpsrc/collection-games.tlpsrc b/Master/tlpkg/tlpsrc/collection-games.tlpsrc
index dc4dfa6ecf0..96c26a5d37d 100644
--- a/Master/tlpkg/tlpsrc/collection-games.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-games.tlpsrc
@@ -28,6 +28,7 @@ depend jigsaw
depend labyrinth
depend logicpuzzle
depend mahjong
+depend maze
depend musikui
depend nimsticks
depend onedown
diff --git a/Master/tlpkg/tlpsrc/maze.tlpsrc b/Master/tlpkg/tlpsrc/maze.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/maze.tlpsrc