git @ Cat's Eye Technologies Nhohnhehr / 5e45f6d
Tidy up repository. Chris Pressey 7 months ago
3 changed file(s) with 207 addition(s) and 209 deletion(s). Raw diff Collapse all Expand all
+0
-2
.hgtags less more
0 c70c2046cb929b3775c0457dfb8c3109631390ff rel_1_0_2011_0510
1 49142375b8a2de1b65fbc3094b87009a4c46c45f rel_1_0_2014_0819
+0
-207
README.markdown less more
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 We can write a program that 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 Here is the program:
155
156 +------------+
157 | /} |
158 |&#/$? \ |
159 | / \& |
160 | |
161 | |
162 | 0 |
163 | ! |
164 | |
165 | |
166 | {1 /# |
167 | { |
168 |\\@ |
169 +------------+
170
171 Computational Class
172 -------------------
173
174 The last example in the previous section was written to demonstrate that
175 Nhohnhehr is at least as powerful as a push-down automaton.
176
177 The author suspects Nhohnhehr to be more powerful still; at least a
178 linear bounded automaton, but possibly even Turing-complete. A strategy
179 for simulating a Turing machine could be developed from the above
180 examples: create new rooms to represent new tape cells, with each
181 possible orientation of the room representing a different tape symbol.
182 The finite control is encoded and embedded in the possible pathways that
183 the instruction pointer can traverse inside each room. Because rooms
184 cannot be changed once created, one might have to resort to creative
185 measures to "change" a tape cell; for instance, each tape cell might
186 have a "stack" of rooms, with a new room appended to the stack each time
187 the cell is to be "changed".
188
189 Source
190 ------
191
192 This document was adapted from [the esolangs.org wiki page for
193 Nhohnhehr](http://www.esolangs.org/wiki/Nhohnhehr), which, like all
194 esowiki articles, has been placed under public domain dedication.
195
196 Implementation
197 --------------
198
199 The Nhohnhehr distribution contains a Nhohnhehr interpreter, written
200 in Python, based on [this implementation of
201 Nhohnhehr](http://esolangs.org/wiki/User:Marinus/Nhohnhehr_interpreter)
202 by [Marinus](http://www.esolangs.org/wiki/User:Marinus). It
203 is effectively the reference interpreter, since it seems to correctly
204 implement the language described here, and there are, to the best of
205 my knowledge, no other implementations of Nhohnhehr in existence.
206 Like all content from the esowiki, it too is in the public domain.
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 We can write a program that 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 Here is the program:
155
156 +------------+
157 | /} |
158 |&#/$? \ |
159 | / \& |
160 | |
161 | |
162 | 0 |
163 | ! |
164 | |
165 | |
166 | {1 /# |
167 | { |
168 |\\@ |
169 +------------+
170
171 Computational Class
172 -------------------
173
174 The last example in the previous section was written to demonstrate that
175 Nhohnhehr is at least as powerful as a push-down automaton.
176
177 The author suspects Nhohnhehr to be more powerful still; at least a
178 linear bounded automaton, but possibly even Turing-complete. A strategy
179 for simulating a Turing machine could be developed from the above
180 examples: create new rooms to represent new tape cells, with each
181 possible orientation of the room representing a different tape symbol.
182 The finite control is encoded and embedded in the possible pathways that
183 the instruction pointer can traverse inside each room. Because rooms
184 cannot be changed once created, one might have to resort to creative
185 measures to "change" a tape cell; for instance, each tape cell might
186 have a "stack" of rooms, with a new room appended to the stack each time
187 the cell is to be "changed".
188
189 Source
190 ------
191
192 This document was adapted from [the esolangs.org wiki page for
193 Nhohnhehr](http://www.esolangs.org/wiki/Nhohnhehr), which, like all
194 esowiki articles, has been placed under public domain dedication.
195
196 Implementation
197 --------------
198
199 The Nhohnhehr distribution contains a Nhohnhehr interpreter, written
200 in Python, based on [this implementation of
201 Nhohnhehr](http://esolangs.org/wiki/User:Marinus/Nhohnhehr_interpreter)
202 by [Marinus](http://www.esolangs.org/wiki/User:Marinus). It
203 is effectively the reference interpreter, since it seems to correctly
204 implement the language described here, and there are, to the best of
205 my knowledge, no other implementations of Nhohnhehr in existence.
206 Like all content from the esowiki, it too is in the public domain.