git @ Cat's Eye Technologies Nhohnhehr / 15ac065
Convert documentation to Markdown. catseye 9 years ago
2 changed file(s) with 193 addition(s) and 163 deletion(s). Raw diff Collapse all Expand all
0 The Nhohnhehr Programming Language
1 ==================================
2
3 Nhohnhehr is a remotely fungeoid esoteric programming language designed
4 by Chris Pressey between December 4 and December 8, 2010.
5
6 Overview
7 --------
8
9 A Nhohnhehr program consists of a single object called a *room*, which
10 is a 2-dimensional, square grid of cells of finite, and usually small,
11 extent. To emphasize its bounds, the single room in a Nhohnhehr program
12 text must be delimited with an ASCII box, in the manner of the
13 following:
14
15 +----+
16 | |
17 | |
18 | |
19 | |
20 +----+
21
22 Arbitrary text, including comments, may occur outside this bounding box;
23 it will not be considered part of the Nhohnhehr program.
24
25 Once defined, the contents of a room are immutable. Although only a
26 single room may appear in a program text, new rooms may be created
27 dynamically at runtime and adjoined to the edges of existing rooms (see
28 below for details on how this works.)
29
30 Execution of Instructions
31 -------------------------
32
33 In a running Nhohnhehr program there is an instruction pointer. At any
34 given time it has a definite position inside one of the rooms of the
35 program, and is traveling in one of the four cardinal directions. It is
36 also associated with a five-state variable called the *edge mode*. As
37 the instruction pointer passes over non-blank cells, it executes them,
38 heeding the following meanings:
39
40 / causes the pointer to travel north if it was traveling east,
41 south if travelling west.
42 \ causes the pointer to travel north if it was traveling west,
43 south if travelling east.
44 = sets wrap edge mode.
45 & sets copy-room-verbatim edge mode.
46 } sets copy-room-rotate-cw-90 edge mode.
47 { sets copy-room-rotate-ccw-90 edge mode.
48 ! sets copy-room-rotate-180 edge mode.
49 # causes the instruction pointer to skip over the next cell
50 (like # in Befunge-93.)
51 ? inputs a bit. If it is 0, rotate direction of travel 90 degrees
52 counterclockwise; if it is 1, rotate direction of travel 90 degress
53 clockwise; if no more input is available, the direction of travel
54 does not change.
55 0 outputs a 0 bit.
56 1 outputs a 1 bit.
57 @ halts the program.
58 $ only indicates where initial instruction pointer is located;
59 otherwise it has no effect. The initial direction of travel is east.
60
61 Blank cells are NOPs.
62
63 Edge Crossing
64 -------------
65
66 If the instruction pointer reaches an edge of the room and tries to
67 cross it, what happens depends on the current edge mode:
68
69 - In wrap edge mode (this is the initial edge mode), the pointer wraps
70 to the corresponding other edge of the room, as if the room were
71 mapped onto a torus.
72 - In all other modes, if there already exists a room adjoining the
73 current room on that edge, the instruction pointer leaves the
74 current room and enters the adjoining room in the corresponding
75 position. However, if no such adjoining room exists yet, one will be
76 created by making a copy of the current room, transforming it
77 somehow, and adjoining it. The instruction pointer then enters the
78 new room, just as if it had already existed. The details of the
79 transformation depend on the edge mode:
80 - In copy-room-verbatim edge mode, no translation is done.
81 - In copy-room-rotate-cw-90 edge mode, the copy of the current
82 room is rotated clockwise 90 degrees before being adjoined.
83 - In copy-room-rotate-ccw-90 edge mode, the copy of the current
84 room is rotated counterclockwise 90 degrees before being
85 adjoined.
86 - In copy-room-rotate-180 edge mode, the copy of the current room
87 is rotated 180 degrees before being adjoined.
88
89 Examples
90 --------
91
92 The following example reads in a sequence of bits and creates a series
93 of rooms, where 1 bits correspond to unrotated rooms and 0 bits
94 correspond to rooms rotated 90 degrees clockwise (though not precisely
95 one-to-one).
96
97 +------+
98 | /}|
99 |&#/$?@|
100 | / \&|
101 | |
102 | { |
103 |\\ |
104 +------+
105
106 After reading a 0 bit and leaving the right edge, the room is copied,
107 rotated 90 degrees clockwise, and adjoined, so that the rooms of the
108 program are:
109
110 +------+------+
111 | /}|\ & |
112 |&#/$?@|\{ # |
113 | / \&| // |
114 | | $ |
115 | { | \?/|
116 |\\ | &@}|
117 +------+------+
118
119 After leaving the right edge again, the current room is copied, this
120 time rotated 90 degrees counterclockwise, and adjoined, and we get:
121
122 +------+------+------+
123 | /}|\ & | /}|
124 |&#/$?@|\{ # |&#/$?@|
125 | / \&| // | / \&|
126 | | $ | |
127 | { | \?/| { |
128 |\\ | &@}|\\ |
129 +------+------+------+
130
131 Say we were to now read in a 1 bit; we would thus have:
132
133 +------+------+------+------+
134 | /}|\ & | /}| /}|
135 |&#/$?@|\{ # |&#/$?@|&#/$?@|
136 | / \&| // | / \&| / \&|
137 | | $ | | |
138 | { | \?/| { | { |
139 |\\ | &@}|\\ |\\ |
140 +------+------+------+------+
141
142 It should be fairly clear at this point that this program will read all
143 input bits, creating rooms thusly, terminating when there are no more
144 input bits.
145
146 The following program is a variation of the above which, when it
147 encounters the end of input, writes out the bits in the reverse order
148 they were read in, with the following changes:
149
150 - for every "1" in the input, a "1" comes out
151 - for every "0" in the input, "10" comes out
152 - there's an extra "1" at the end of the output
153
154 +------------+
155 | /} |
156 |&#/$? \ |
157 | / \& |
158 | |
159 | |
160 | 0 |
161 | ! |
162 | |
163 | |
164 | {1 /# |
165 | { |
166 |\\@ |
167 +------------+
168
169 Computational Class
170 -------------------
171
172 The last example in the previous section was written to demonstrate that
173 Nhohnhehr is at least as powerful as a push-down automaton.
174
175 The author suspects Nhohnhehr to be more powerful still; at least a
176 linear bounded automaton, but possibly even Turing-complete. A strategy
177 for simulating a Turing machine could be developed from the above
178 examples: create new rooms to represent new tape cells, with each
179 possible orientation of the room representing a different tape symbol.
180 The finite control is encoded and embedded in the possible pathways that
181 the instruction pointer can traverse inside each room. Because rooms
182 cannot be changed once created, one might have to resort to creative
183 measures to "change" a tape cell; for instance, each tape cell might
184 have a "stack" of rooms, with a new room appended to the stack each time
185 the cell is to be "changed".
186
187 Source
188 ------
189
190 This document was adapted from [the esolangs.org wiki page for
191 Nhohnhehr](http://www.esolangs.org/wiki/Nhohnhehr), which, like all
192 esowiki articles, has been placed under public domain dedication.
+0
-163
doc/nhohnhehr.html less more
0 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
1 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
2 <head>
3 <title>The Nhohnhehr Programming Language</title>
4 <!-- begin html doc dynamic markup -->
5 <script type="text/javascript" src="/contrib/jquery-1.6.4.min.js"></script>
6 <script type="text/javascript" src="/scripts/documentation.js"></script>
7 <!-- end html doc dynamic markup -->
8 </head>
9 <body>
10
11 <h1>The Nhohnhehr Programming Language</h1>
12
13 <p><dfn>Nhohnhehr</dfn> is a remotely fungeoid esoteric programming language
14 designed by Chris Pressey between December 4 and December 8, 2010.</p>
15
16 <h2>Overview</h2>
17
18 <p>A Nhohnhehr program consists of a single object called a <i>room</i>, which is a 2-dimensional, square grid
19 of cells of finite, and usually small, extent. To emphasize its bounds, the single room in a Nhohnhehr program text
20 must be delimited with an ASCII box, in the manner of the following:
21 </p>
22 <pre>+----+
23 | |
24 | |
25 | |
26 | |
27 +----+
28 </pre>
29 <p>Arbitrary text, including comments, may occur outside this bounding box; it will not be considered part of the Nhohnhehr program.
30 </p><p>Once defined, the contents of a room are immutable. Although only a single room may appear in a program text, new rooms
31 may be created dynamically at runtime and adjoined to the edges of existing rooms (see below for details on how this works.)
32 </p>
33
34 <h2>Execution of Instructions</h2>
35
36 <p>In a running Nhohnhehr program there is an instruction pointer. At any given time it has a definite position inside one of the
37 rooms of the program, and is traveling in one of the four cardinal directions. It is also associated with a five-state variable called the
38 <i>edge mode</i>. As the instruction pointer passes over non-blank cells, it executes them, heeding the following meanings:</p>
39
40 <pre> / causes the pointer to travel north if it was traveling east, south if travelling west.
41 \ causes the pointer to travel north if it was traveling west, south if travelling east.
42 = sets wrap edge mode.
43 &amp; sets copy-room-verbatim edge mode.
44 } sets copy-room-rotate-cw-90 edge mode.
45 { sets copy-room-rotate-ccw-90 edge mode.
46 ! sets copy-room-rotate-180 edge mode.
47 # causes the instruction pointer to skip over the next cell (like # in Befunge-93.)
48 ? inputs a bit. If it is 0, rotate direction of travel 90 degrees counterclockwise;
49 if it is 1, rotate direction of travel 90 degress clockwise; if no more input is
50 available, the direction of travel does not change.
51 0 outputs a 0 bit.
52 1 outputs a 1 bit.
53 @ halts the program.
54 $ only indicates where initial instruction pointer is located; otherwise it has no effect.
55 The initial direction of travel is east.
56 blank cells are NOPs.
57 </pre>
58
59 <h2>Edge Crossing</h2>
60
61 <p>If the instruction pointer reaches an edge of the room and tries to cross it, what happens depends on the current edge mode:
62 </p>
63 <ul><li> In wrap edge mode (this is the initial edge mode), the pointer wraps to the corresponding other edge of the room, as if the room were mapped onto a torus.
64 </li><li> In all other modes, if there already exists a room adjoining the current room on that edge, the instruction pointer leaves the current room and enters the adjoining room in the corresponding position. However, if no such adjoining room exists yet, one will be created by making a copy of the current room, transforming it somehow, and adjoining it. The instruction pointer then enters the new room, just as if it had already existed. The details of the transformation depend on the edge mode:
65 <ul><li> In copy-room-verbatim edge mode, no translation is done.
66 </li><li> In copy-room-rotate-cw-90 edge mode, the copy of the current room is rotated clockwise 90 degrees before being adjoined.
67 </li><li> In copy-room-rotate-ccw-90 edge mode, the copy of the current room is rotated counterclockwise 90 degrees before being adjoined.
68 </li><li> In copy-room-rotate-180 edge mode, the copy of the current room is rotated 180 degrees before being adjoined.
69 </li></ul>
70 </li></ul>
71
72 <h2>Examples</h2>
73
74 <p>The following example reads in a sequence of bits and creates a series of rooms, where 1 bits correspond to unrotated rooms and 0 bits correspond to rooms rotated 90 degrees clockwise (though not precisely one-to-one).
75 </p>
76 <pre>+------+
77 | /}|
78 |&amp;#/$?@|
79 | / \&amp;|
80 | |
81 | { |
82 |\\ |
83 +------+
84 </pre>
85 <p>After reading a 0 bit and leaving the right edge, the room is copied, rotated 90 degrees clockwise, and adjoined, so that the rooms of the program are:
86 </p>
87 <pre>+------+------+
88 | /}|\ &amp; |
89 |&amp;#/$?@|\{ # |
90 | / \&amp;| // |
91 | | $ |
92 | { | \?/|
93 |\\ | &amp;@}|
94 +------+------+
95 </pre>
96 <p>After leaving the right edge again, the current room is copied, this time rotated 90 degrees counterclockwise, and adjoined, and we get:
97 </p>
98
99 <pre>+------+------+------+
100 | /}|\ &amp; | /}|
101 |&amp;#/$?@|\{ # |&amp;#/$?@|
102 | / \&amp;| // | / \&amp;|
103 | | $ | |
104 | { | \?/| { |
105 |\\ | &amp;@}|\\ |
106 +------+------+------+
107 </pre>
108 <p>Say we were to now read in a 1 bit; we would thus have:
109 </p>
110 <pre>+------+------+------+------+
111 | /}|\ &amp; | /}| /}|
112 |&amp;#/$?@|\{ # |&amp;#/$?@|&amp;#/$?@|
113 | / \&amp;| // | / \&amp;| / \&amp;|
114 | | $ | | |
115 | { | \?/| { | { |
116 |\\ | &amp;@}|\\ |\\ |
117 +------+------+------+------+
118
119 </pre>
120 <p>It should be fairly clear at this point that this program will read all input bits, creating rooms thusly, terminating when there are no more input bits.
121 </p><p>The following program is a variation of the above which, when it encounters the end of input, writes out the bits in the reverse order they were read in, with the following changes:
122 </p>
123 <ul><li> for every "1" in the input, a "1" comes out
124 </li><li> for every "0" in the input, "10" comes out
125 </li><li> there's an extra "1" at the end of the output
126 </li></ul>
127 <pre>+------------+
128 | /} |
129 |&amp;#/$? \ |
130 | / \&amp; |
131 | |
132 | |
133 | 0 |
134 | ! |
135 | |
136 | |
137 | {1 /# |
138 | { |
139 |\\@ |
140 +------------+
141 </pre>
142
143 <h2>Computational Class</h2>
144
145 <p>The last example in the previous section was written to demonstrate that Nhohnhehr is at least as powerful as a
146 push-down automaton.</p>
147
148 <p>The author suspects Nhohnhehr to be more powerful still; at least a linear bounded automaton,
149 but possibly even Turing-complete. A strategy for simulating a Turing machine could be developed from the above examples:
150 create new rooms to represent new tape cells, with each possible orientation of the room representing a different tape symbol.
151 The finite control is encoded and embedded in the possible pathways that the instruction pointer can traverse inside each room.
152 Because rooms cannot be changed once created, one might have to resort to creative measures to "change" a tape cell; for
153 instance, each tape cell might have a "stack" of rooms, with a new room appended to the stack each time the cell is to be "changed".</p>
154
155 <h2>Source</h2>
156
157 <p>This document was adapted from
158 <a class="external" href="http://www.esolangs.org/wiki/Nhohnhehr">the esolangs.org wiki page for Nhohnhehr</a>,
159 which, like all esowiki articles, has been placed under public domain dedication.</p>
160
161 </body>
162 </html>