git @ Cat's Eye Technologies Braktif / e268bcf
Put license and README in separate files from definition. catseye 7 years ago
3 changed file(s) with 104 addition(s) and 102 deletion(s). Raw diff Collapse all Expand all
0 Copyright (c)2005-2013 Chris Pressey, Cat's Eye Technologies.
1 All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions
5 are met:
6
7 1. Redistributions of source code must retain the above copyright
8 notices, this list of conditions and the following disclaimer.
9 2. Redistributions in binary form must reproduce the above copyright
10 notices, this list of conditions, and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 3. Neither the names of the copyright holders nor the names of their
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 POSSIBILITY OF SUCH DAMAGE.
0 Braktif
1 =======
2
3 Braktif is an esoteric programming language very similar to
4 _Brainfuck F_ and _Archway_, with a small but significant
5 difference: Braktif is formulated as a 28-state cellular automaton.
6
7 Braktif playfields are divided into a program on the right and
8 a data storage area on the left. (The data storage area can be
9 considered to extend indefinately to the left.) The program
10 and data area are connected by a "bus". On the bus sit the
11 instruction pointer, which rests underneath the part of the
12 program which is currently executing, and the data pointer, which
13 rests underneath the part of the storage which is currently being
14 addressed. The instruction pointer and data pointer communicate
15 by means of signals (from the IP to the DP) and replies (from the
16 DP to the IP) sent along the bus.
17
18 The instructions of a Braktif program resemble those of Smallfuck
19 or Brainfuck F:
20
21 * flip current data bit
22 > advance DP one cell to the right
23 < advance DP one cell to the left
24 [ if current data bit == 0, skip to matching ]
25 ] skip back to matching [
26
27 The structure of Braktif programs resembles that of Archway. Each
28 nested loop must be raised up one level. In addition, extra space
29 must be left after `[` instructions, and at least one non-`[]`
30 instruction must occur after a `]` instruction, so that signals have
31 sufficient space in which to propagate.
32
33 The data storage area of a Braktif playfield resembles the tape of
34 a Brainfuck F program (or a Smallfuck program, if an arbitrary limit
35 is imposed on it) except that it is bounded on the *right*, not the
36 left.
37
38 The final result of all this is that the following Brainfuck F
39 program translates to the following Braktif program (the `...`
40 indicates the quiescent repeating pattern extending off to infinity):
41
42 Brainfuck F:
43
44 +[>+]
45
46 Braktif:
47 <*
48 ... 00000000000000 *[---]
49 ... -------------d-i- --
50
51 So... why Braktif?
52
53 - eliminates "spooky action at a distance" from the Brainfuck model:
54 the communication between the code and the tape is made explicit
55 (and explicitly planar, FWIW WRT the wire-crossing problem.)
56 - horribly inefficient because of this. Flipping the _n_'th data cell
57 from the _m_'th instruction of the program is now an O(_n_+_m_)
58 operation. What fun!
59 - makes a passable "poor man's visual debugger" for Brainfuck F.
60 - makes experimenting with concurrent models easily. For example it
61 might be feasible to add a few states what would act as a simple
62 mutex so that two different programs could share one data store.
63
64 Finally, I do not claim that this is the most efficient formulation
65 imaginable... there is certainly room for optimization. For
66 example, half of the `Tool` states could probably be done away with
67 entirely if the signals were to transition themselves directly into
68 responses. But a minimum of states is not the real goal (otherwise
69 one could just settle for John Conway's Game of Life and be done
70 with it,) and the `Tool` states lend a certain straightforwardness.
00 /*
11 * The Braktif Cellular Automaton
2 * June 2005, Chris Pressey
3 * BSD License added May 3 2007
4 */
5
6 /*
7 * Copyright (c)2007 Chris Pressey, Cat's Eye Technologies.
8 * All rights reserved.
2 * A brainfuck-like programming language in a 28-state cellular automaton.
3 * Covered under a BSD-style license; see LICENSE for more information.
94 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright
15 * notices, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notices, this list of conditions, and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 * 3. Neither the names of the copyright holders nor the names of their
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
5 * June 2005: original design and definition of the Braktif CA.
6 * May 3 2007: added BSD license.
367 */
378
38 /*
39 * Braktif is an esoteric programming language very similar to
40 * 'Brainfuck F' and 'Archway', with a small but significant
41 * difference: Braktif is formulated as a 28-state cellular automaton.
42 *
43 * Braktif playfields are divided into a program on the right and
44 * a data storage area on the left. (The data storage area can be
45 * considered to extend indefinately to the left.) The program
46 * and data area are connected by a 'bus'. On the bus sit the
47 * instruction pointer, which rests underneath the part of the
48 * program which is currently executing, and the data pointer, which
49 * rests underneath the part of the storage which is currently being
50 * addressed. The instruction pointer and data pointer communicate
51 * by means of signals (from the IP to the DP) and replies (from the
52 * DP to the IP) sent along the bus.
53 *
54 * The instructions of a Braktif program resemble those of Smallfuck
55 * or Brainfuck F:
56 *
57 * * flip current data bit
58 * > advance DP one cell to the right
59 * < advance DP one cell to the left
60 * [ if current data bit == 0, skip to matching ]
61 * ] skip back to matching [
62 *
63 * The structure of Braktif programs resembles that of Archway. Each
64 * nested loop must be raised up one level. In addition, extra space
65 * must be left after [ instructions, and at least one non-[]
66 * instruction must occur after a ] instruction, so that signals have
67 * sufficient space in which to propagate.
68 *
69 * The data storage area of a Braktif playfield resembles the tape of
70 * a Brainfuck F program (or a Smallfuck program, if an arbitrary limit
71 * is imposed on it) except that it is bounded on the *right*, not the
72 * left.
73 *
74 * The final result of all this is that the following Brainfuck F
75 * program translates to the following Braktif program (the '...'
76 * indicates the quiescent repeating pattern extending off to infinity):
77 *
78 * Brainfuck F: +[>+]
79 *
80 * Braktif:
81 * <*
82 * ... 00000000000000 *[---]
83 * ... -------------d-i- --
84 *
85 * So... why Braktif?
86 *
87 * - eliminates 'spooky action at a distance' from the Brainfuck model:
88 * the communication between the code and the tape is made explicit
89 * (and explicitly planar, FWIW WRT the wire-crossing problem.)
90 * - horribly inefficient because of this. Flipping the n'th data cell
91 * from the m'th instruction of the program is now an O(n+m) operation.
92 * What fun!
93 * - makes a passable "poor man's visual debugger" for Brainfuck F.
94 * - makes experimenting with concurrent models easily. For example it
95 * might be feasible to add a few states what would act as a simple
96 * mutex so that two different programs could share one data store.
97 *
98 * Finally, I do not claim that this is the most efficient formulation
99 * imaginable... there is certainly room for optimization. For
100 * example, half of the 'Tool' states could probably be done away with
101 * entirely if the signals were to transition themselves directly into
102 * responses. But a minimum of states is not the real goal (otherwise
103 * one could just settle for John Conway's Game of Life and be done
104 * with it,) and the 'Tool' states lend a certain straightforwardness.
105 */
106
1079 /* -------------------- Transmission Media --------------------- */
10810
10911 state Space " "