PageSourceSearch

https://www.puzzlescript.net/Documentation/rules101.html

html puzzlescript.net collected 2026-10-03 19:05:45 UTC 7,473 bytes, 164 lines download raw bytes

1<!DOCTYPE html>
2<html lang="en">
3  <head>
4    <meta charset="utf-8">
5    <meta name="viewport" content="width=device-width, initial-scale=1.0">
6    <meta name="description" content="">
7    <meta name="author" content="">
8    <link rel="shortcut icon" type="image/x-icon" href="ico/favicon.ico" />
9
10    <title>Rules 101 - PuzzleScript Documentation</title>
11
12    <!-- Bootstrap core CSS -->
13    <link href="css/bootstrap.css" rel="stylesheet">
14
15    <!-- Custom styles for this template -->
16    <link href="css/bootstrap-theme.css" rel="stylesheet">
17    <link href="css/doc-code.css" rel="stylesheet">
18
19    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
20    <!--[if lt IE 9]>
21      
21<script src="../../assets/js/html5shiv.js"></script>
21
22      
22<script src="../../assets/js/respond.min.js"></script>
22
23    <![endif]-->
24  </head>
25
26  <body>
27
28    <div class="navbar navbar-inverse navbar-fixed-top">
29      <div class="container">
30        <div class="navbar-header">
31          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
32            <span class="icon-bar"></span>
33            <span class="icon-bar"></span>
34            <span class="icon-bar"></span>
35          </button>         
36          <a class="navbar-brand" href="../index.html"><img src="../images/mascot_colorful.png"> PuzzleScript</a>
37        </div>
38        <div class="collapse navbar-collapse">
39          <ul class="nav navbar-nav">
40              <li><a href="../editor.html">Make A Game</a></li>
41              
42              <li class="active"><a href="documentation.html">Documentation</a></li>
43          </ul>          
44          <ul class="nav navbar-nav navbar-right">
45            <li><a href="https://groups.google.com/g/puzzlescript">Forum</a></li>
46            <li><a href="https://github.com/increpare/puzzlescript">GitHub</a></li>
47            <li><a href="https://github.com/sponsors/increpare">Sponsor</a></li>
48            <li><a href="about.html">About</a></li>
49          </ul>
50        </div><!--/.nav-collapse -->
51      </div>
52    </div>
53
54    <div class="container">
55
56
57<p>
58<ol class="breadcrumb">
59  <li><a href="documentation.html">Documentation</a></li>
60  <li class="active">Rules 101</li>
61</ol>
62<p>
63
64
65
66<h2>Rules 101</h2>
67<p>
68PuzzleScript is a game engine designed to help you make tile-based puzzle games.  The most famous tile-based puzzle game is sokoban:
69<p>
70<img src="images/sokoban.gif">
71<p>
72Sokoban has one rule:
73<ul>
74<li>If a player is trying to walk into a crate, try to push that crate.</li>
75</ul>
76<p>
77PuzzleScript allows you to express this succinctly:
78<p>
79<pre><code><a href="../editor.html?demo=sokoban_basic" target="puzzleScript_EditorWindow" class="btn btn-default pull-right" ><span class="glyphicon"> Edit</span></a>[ > Player | Crate ] -> [ > Player | > Crate ]</code></pre>
80<p>
81The engine looks for the pattern on the left, and replaces it with the one on the right.  
82<p>
83<b>></b> is a directional arrow.  The four arrows are <b>&lt;</b>, <b>></b>, <b>^</b>, and <b>v</b>.
84<p>
85Let's play with the above line of code - what would happen if we changed the direction of the arrows?
86<p>
87<pre><code><a href="../editor.html?demo=sokoban_sticky" target="puzzleScript_EditorWindow" class="btn btn-default pull-right" ><span class="glyphicon"> Edit</span></a>[ &lt; Player | Crate ] -> [ &lt; Player | &lt; Crate ]</code></pre>
88<p>
89Now, the crates stick to you you when you move away from them!
90<p>
91<img src="images/sokoban_reversed.gif">
92<p>
93The engine works like this:
94<p>
95<ol>
96<li>The player is marked as being someone who wants to move</li>
97<li>Each of your rules is applied as often as it can be.</li>
98<li>Movement happens.</li>
99<li>An optional extra stage for rules you want to apply at the very end.</li>
100</ol>
101<p>
102What might you want to do after movements have been applied?  Say you want three crates in a row to vanish (a la <a href="../editor.html?demo=blockfaker">block faker</a>), you do this by adding the following rule:
103<p>
104<pre><code><a href="../editor.html?demo=sokoban_match3" target="puzzleScript_EditorWindow" class="btn btn-default pull-right" ><span class="glyphicon"> Edit</span></a>late [ Crate | Crate | Crate ] -> [ | | ]</code></pre>
105<p>
106<img src="images/sokoban_match3.gif">
107<p>
108If the late keyword wasn't there, the crates wouldn't disappear until the start of the next turn.
109<p>
110Let's have spooky eyeballs that follow you around.
111<p>
112<pre><code><a href="../editor.html?demo=sokoban_eyeball" target="puzzleScript_EditorWindow" class="btn btn-default pull-right" ><span class="glyphicon"> Edit</span></a>[ Eyeball | ... | Player ] -> [ > Eyeball | ... | Player ]</code></pre>
113<p>
114<img src="images/eyefollow.gif">
115<p>
116Here's a naughty teleport sprite - whenever she sees you she swaps places with you:
117<p>
118<pre><code>late [ Sprite | ... | Player ] -> [ Player | ... | Sprite ]</code></pre>
119<p>
120<em>No, wait!  Don't type that in.</em> It causes an infinite loop, it keeps swapping them back and forth forever.  This fixes it:
121<p>
122<pre><code><a href="../editor.html?demo=naughtysprite" target="puzzleScript_EditorWindow" class="btn btn-default pull-right" ><span class="glyphicon"> Edit</span></a>late [ Sprite | ... | Player ] -> [ Temp | ... | Sprite ]
123late [ Temp ] -> [ Player ]</code></pre>
124<p>
125<img src="images/sokoban_fairy.gif">
126<p>
127What if you're <a href="http://www.lexaloffle.com/neko.htm">a kitty that likes fruit?</a>
128<p>
129<pre><code><a href="../editor.html?demo=nekopuzzle" target="puzzleScript_EditorWindow" class="btn btn-default pull-right" ><span class="glyphicon"> Edit</span></a>[ > Kitty | ... | Fruit ] -> [ | ... | Kitty ]
130[ > Kitty ] -> [ Kitty ]</code></pre>
131<p>
132The second line is because we are moving the kitty ourselves, and don't want the game engine letting kitty wander about.
133<p>
134<img src="images/nekopuzzle.gif">
135<p>
136What if you want crates that can only be pushed horizontally? 
137<p>
138<pre><code><a href="../editor.html?demo=sokoban_horizontal" target="puzzleScript_EditorWindow" class="btn btn-default pull-right" ><span class="glyphicon"> Edit</span></a>Horizontal [ > Player | Block ] -> [ > Player | > Block ]</code></pre>
139<p>
140This only looks for occurrences of the pattern that are horizontal. You could also say vertical instead.
141<p>
142<img src="images/horizontalblock.gif">
143<p>
144You can have several patterns rather than just a single row - here's a sumo wrestler that imitates whatever you do, wherever you are:
145<p>
146<pre><code><a href="../editor.html?demo=sumo" target="puzzleScript_EditorWindow" class="btn btn-default pull-right" ><span class="glyphicon"> Edit</span></a>[ > Player ] [ Sumo ] -> [ > Player ] [ > Sumo ]</code></pre>
147<p>
148<img src="images/sumo.gif">
149<p>
150That about covers all the basics.  You should be able to tinker with the examples now.  There's <a href="documentation.html">plenty more</a> to read if you want to, but I would advise to learn the rest on a need-to-know basis.  There're no prizes for knowing all the nooks and crannies of PuzzleScript - it's a tool for making games, and if you're not doing that with it, then the engine has failed in its purpose.
151<p>
152<a href="../editor.html">Make some games!</a>
153<p>
154
155    </div><!-- /.container -->
156
157
158    <!-- Bootstrap core JavaScript
159    ================================================== -->
160    <!-- Placed at the end of the document so the pages load faster -->
161    
161<script src="js/jquery.js"></script>
161
162    
162<script src="js/bootstrap.min.js"></script>
162
163  </body>
164</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.