Re: Thread for your website-related questions
But there's a problem: not everyone can use and know how to use Nutshell; I doesn't even understand a single pixel of the readme file. Can Nutshell have GUI?
Forums for Conway's Game of Life
https://conwaylife.com/forums/
But there's a problem: not everyone can use and know how to use Nutshell; I doesn't even understand a single pixel of the readme file. Can Nutshell have GUI?
Note: I did not go far beyond skimming the documentation / examples.
This is basically one of points where I disagree.dvgrn wrote: April 12th, 2024, 9:51 am[...]Here's a quote from the documentation:
[...]Variables
All variable names are unbound, always, because needing to define eight separate "any state" vars is ridiculous.
That's not to say, however, that there is no concept of binding variables in Nutshell! It's just that you don't bind by name. Nutshell's actual idea of binding is explained later on.
Well... a GUI could certainly be built (using Golly's Lua overlay, for example) that would write out Nutshell ".ruel" tables, which would then transpile to actual Golly ruletables.b-engine wrote: April 12th, 2024, 10:20 am But there's a problem: not everyone can use and know how to use Nutshell; I doesn't even understand a single pixel of the readme file. Can Nutshell have GUI?
Nothing is wrong with that at all -- that's exactly what Nutshell does (if I'm understanding this correctly). The point of Nutshell is to allow a more compact and easier-to-edit notation, that produces plain-vanilla ruletables that would be really difficult to generate manually.confocaloid wrote: April 12th, 2024, 10:27 am If the ruletable is autogenerated from some source, then, well, what's wrong with autogenerating eight separate vars for eight separate independent variables?
I think the idea is interesting. With a "sigil" used directly within the affected rule, reading a single rule suffices to understand where are bound variables, and where are "one-time" variables not bound to any name. (Anyway that would be better than having to scroll back and forth to declarations of variables while reading.)
Code: Select all
var a={2,5}Code: Select all
3, *a, *a, a, 0, 0, 0, 0, 0, aCode: Select all
3, 2, 2, 2, 0, 0, 0, 0, 0, 2
3, 2, 5, 2, 0, 0, 0, 0, 0, 2
3, 5, 2, 2, 0, 0, 0, 0, 0, 2
3, 5, 5, 2, 0, 0, 0, 0, 0, 2
3, 2, 2, 5, 0, 0, 0, 0, 0, 5
3, 2, 5, 5, 0, 0, 0, 0, 0, 5
3, 5, 2, 5, 0, 0, 0, 0, 0, 5
3, 5, 5, 5, 0, 0, 0, 0, 0, 5
After some more thought, I think the best sigil would be &, sort of like int& in C++ where it makes a "reference" to an int variable which behaves like it's a normal int but it just references the original variable that was referenced.confocaloid wrote: April 13th, 2024, 1:52 am One will need to choose the syntax. Prefixing a tilde makes it easy to misread "~a" as negation of the value of "a".
Maybe prefix with asterisk instead? Or that would be confusing too, for some other reason?
Code: Select all
var a={3,4}
0, a[1], a[1], a[1], a[1], a[2], a[2], a[2], a[2], 1
Code: Select all
0, 3, 3, 3, 3, 3, 3, 3, 3, 1
0, 3, 3, 3, 3, 4, 4, 4, 4, 1
0, 4, 4, 4, 4, 3, 3, 3, 3, 1
0, 4, 4, 4, 4, 4, 4, 4, 4, 1
Code: Select all
var a={3,4}
var b={3,4}
0, a, a, a, a, b, b, b, b, 1
Code: Select all
var a={3,4}
0, a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], 1
I'm not sure it's a good idea to allow negation inside a rule. What would the following expand to? (Note that there are two occurrences of "a" and two occurrences of "~a" in a single rule.)wirehead wrote: April 13th, 2024, 11:21 am[...]
Also, with regards to ~ meaning negate, that might also be worthwhile to implement natively, so that you don't have to make two variables for A and notA. (And this would also apply to individual states, too so that in a 5 state rule writing ~3 means {0, 1 2, 4}.) [...]
Code: Select all
n_states:5
var a={2, 3, 4}
0, 0, 0, a, a, ~a, ~a, 0, 0, 1
Code: Select all
0, 0, 0, 2, 2, 3, 3, 0, 0, 1
0, 0, 0, 2, 2, 4, 4, 0, 0, 1
0, 0, 0, 3, 3, 2, 2, 0, 0, 1
0, 0, 0, 3, 3, 4, 4, 0, 0, 1
0, 0, 0, 4, 4, 2, 2, 0, 0, 1
0, 0, 0, 4, 4, 3, 3, 0, 0, 1Code: Select all
0, 0, 0, 2, 2, 2, 2, 0, 0, 1
0, 0, 0, 3, 3, 1, 1, 0, 0, 1
0, 0, 0, 4, 4, 0, 0, 0, 0, 1Do you think arithmetic operations should accept and return sets?wirehead wrote: April 13th, 2024, 11:21 am[...] We could go even farther and allow even more set operations on variables, such as a+b for set union, a-b for asymmetric subtraction, a^b for symmetric difference, a*b for intersection, etc. But then we run the risk of making Golly rule tables turing complete which may or may not be the goal.
Code: Select all
n_states:16
var a={2,3,10}
var b={1,5}
0, 0, 0, 0, 0, 0, a, b, a+b, a+b
Code: Select all
n_states:16
0, 0, 0, 0, 0, 0, 2, 1, 3, 3
0, 0, 0, 0, 0, 0, 2, 5, 7, 7
0, 0, 0, 0, 0, 0, 3, 1, 4, 4
0, 0, 0, 0, 0, 0, 3, 5, 8, 8
0, 0, 0, 0, 0, 0, 10, 1, 11, 11
0, 0, 0, 0, 0, 0, 10, 5, 15, 15
I was thinking more along the lines of typical set negation you learn in high school algebra 2 class -- i.e. "not A" means the same as U-A where U is all allowed cellstates. So if it is a 10 state rule and a={3,4,6,7} then ~a={0,1,2,5,8,9}.confocaloid wrote: April 13th, 2024, 2:27 pm I'm not sure it's a good idea to allow negation inside a rule. ... Neither of these possibilities feels like "the single best choice" to me.
Yeah, that is what Python uses instead of the mathy symbols a∪b, a∩b which aren't ASCII, and a\b which more often than not causes parsing problems.confocaloid wrote: April 13th, 2024, 2:27 pm Do you think arithmetic operations should accept and return sets?
You, perhaps, but I am not as familiar with vector/matrix math that this seems most like. Why should A+B mean sum of all combinations, versus set union? If this behavior is desired, I think the asterisk operator * and thinking of it as "multiplying" two sets to produce a matrix of permutations would suffice.confocaloid wrote: April 13th, 2024, 2:27 pm I believe arithmetic with single cellstates would be more useful and intuitive.
Not really. What I described in my previous post wouldn't need vectors or matrices. It would be integer arithmetic with state values.wirehead wrote: April 13th, 2024, 5:21 pm[...]You, perhaps, but I am not as familiar with vector/matrix math that this seems most like. Why should A+B mean sum of all combinations, versus set union? If this behavior is desired, I think the asterisk operator * and thinking of it as "multiplying" two sets to produce a matrix of permutations would suffice.confocaloid wrote: April 13th, 2024, 2:27 pm I believe arithmetic with single cellstates would be more useful and intuitive.
[...]
Code: Select all
3, 0, a, 0, b, 0, a + b, 0, a - b, 4Code: Select all
3, 0, 5, 0, 0, 0, 5, 0, 5, 4
3, 0, 5, 0, 3, 0, 8, 0, 2, 4
3, 0, 6, 0, 0, 0, 6, 0, 6, 4
3, 0, 6, 0, 3, 0, 9, 0, 3, 4
Code: Select all
@TABLE
neighborhood: Moore
n_states: 10
symmetries: permute
overflow: saturation
var a={1,2,3,4,5,6,7,8,9}
var x={0,1,2,3,4,5,6,7,8,9}
0, a[1], a[2], a[3], 0, 0, 0, 0, 0, 1 # a state-1 cell is born when it has exactly three nonzero neighbours
a[0], a[1], a[2], a[3], 0, 0, 0, 0, 0, a[0]+1 # a nonzero cell survives when it has exactly three...
a[0], a[1], a[2], 0, 0, 0, 0, 0, 0, a[0]+1 # ... or two nonzero neighbours
x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], 0 # otherwise, every cell becomes or remains 0
Code: Select all
@TABLE
neighborhood:Moore
n_states:10
symmetries:permute
var a1={1,2,3,4,5,6,7,8,9}
var a2=a1
var a3=a1
var x={0,1,2,3,4,5,6,7,8,9}
var x1=x
var x2=x
var x3=x
var x4=x
var x5=x
var x6=x
var x7=x
var x8=x
0, a1, a2, a3, 0, 0, 0, 0, 0, 1
1, a1, a2, a3, 0, 0, 0, 0, 0, 2
2, a1, a2, a3, 0, 0, 0, 0, 0, 3
3, a1, a2, a3, 0, 0, 0, 0, 0, 4
4, a1, a2, a3, 0, 0, 0, 0, 0, 5
5, a1, a2, a3, 0, 0, 0, 0, 0, 6
6, a1, a2, a3, 0, 0, 0, 0, 0, 7
7, a1, a2, a3, 0, 0, 0, 0, 0, 8
8, a1, a2, a3, 0, 0, 0, 0, 0, 9
9, a1, a2, a3, 0, 0, 0, 0, 0, 9
1, a1, a2, 0, 0, 0, 0, 0, 0, 2
2, a1, a2, 0, 0, 0, 0, 0, 0, 3
3, a1, a2, 0, 0, 0, 0, 0, 0, 4
4, a1, a2, 0, 0, 0, 0, 0, 0, 5
5, a1, a2, 0, 0, 0, 0, 0, 0, 6
6, a1, a2, 0, 0, 0, 0, 0, 0, 7
7, a1, a2, 0, 0, 0, 0, 0, 0, 8
8, a1, a2, 0, 0, 0, 0, 0, 0, 9
9, a1, a2, 0, 0, 0, 0, 0, 0, 9
x, x1, x2, x3, x4, x5, x6, x7, x8, 0
"a[4]" looks like taking an element of an array "a", precisely because it is meant to be readable as "taking an element of an array of variables".squareroot12621 wrote: April 13th, 2024, 6:59 pm [...] However, I'm not a huge fan of the a[n] syntax for "copy n of the array a", because it looks like you're taking the nᵗʰ element of a. [...]
Code: Select all
var a={3,4,5}A disadvantage of using the dot is that it would not highlight the fact that all variables a.something have the exact same set of allowed values. That would be similar to the syntax used for accessing a member of a struct/record in several programming languages, and members of a struct/record can have different types.squareroot12621 wrote: April 13th, 2024, 6:59 pm [...] If I had to suggest an alternative, I would choose a.n, which (I think) is what Nutshell already internally uses.
Yes, a[4] does give you an element of a. (As does anything with a at the beginning.) However, to me, it looks like it's taking specifically the fourth element of a, not any of the others.confocaloid wrote: April 13th, 2024, 7:14 pm"a[4]" looks like taking an element of an array "a", precisely because it is meant to be readable as "taking an element of an array of variables".…squareroot12621 wrote: April 13th, 2024, 6:59 pm [...] However, I'm not a huge fan of the a[n] syntax for "copy n of the array a", because it looks like you're taking the nᵗʰ element of a. [...]
…Then what else would we use? a#n, maybe?confocaloid wrote: April 13th, 2024, 7:14 pm …A disadvantage of using the dot is that it would not highlight the fact that all variables a.something have the exact same set of allowed values. That would be similar to the syntax used for accessing a member of a struct/record in several programming languages, and members of a struct/record can have different types.squareroot12621 wrote: April 13th, 2024, 6:59 pm [...] If I had to suggest an alternative, I would choose a.n, which (I think) is what Nutshell already internally uses.
In the existing ruletable syntax, writingsquareroot12621 wrote: April 13th, 2024, 8:33 pmYes, a[4] does give you an element of a. (As does anything with a at the beginning.) However, to me, it looks like it's taking specifically the fourth element of a, not any of the others.confocaloid wrote: April 13th, 2024, 7:14 pm[...]
"a[4]" looks like taking an element of an array "a", precisely because it is meant to be readable as "taking an element of an array of variables".…
Just to be clear: If a were defined to {0, 1, 2, 3, 4}, would a[4] refer to (A) just state 3, or (B) an independent copy of a?
Code: Select all
var a={0, 1, 2, 3, 4}Code: Select all
1, a, a, a, a, a, a, a, a, 2Code: Select all
var a={0, 1, 2, 3, 4}Code: Select all
1, a[1], a[2], a[3], a[4], a[1], a[2], a[3], a[4], 2Code: Select all
1, a[1], a[1], a[2], a[2], a[2], a[3], a[3], a[3], 2As a side note, in the existing Golly ruletable syntax, the meanings of the colon ':' and the equals sign '=' are exchanged.confocaloid wrote: April 13th, 2024, 8:58 pm[...] Note that in the above, the variable a is not an array. It doesn't have any smaller elements. Its value is a single cellstate. [...]squareroot12621 wrote: April 13th, 2024, 8:33 pm [...] However, to me, it looks like it's taking specifically the fourth element of a, not any of the others. [...]
Code: Select all
@TABLE
n_states:3
neighborhood:Moore
symmetries:permute
var d={0,2}
var d1=d
var d2=d
Code: Select all
@TABLE
n_states=3
neighborhood=Moore
symmetries=permute
var d: {0,2}
var d1: d
var d2: d
This other topic seems mildly related, so I’m linking to it.confocaloid wrote: April 16th, 2024, 10:23 am Bump "Re: Rule Tables + Weighted Life + Larger than Life"
wirehead wrote: April 13th, 2024, 11:21 am[...] But then we run the risk of making Golly rule tables turing complete which may or may not be the goal.
I think precomputing the rules using a PRNG wouldn't be a particularly serious problem. It would just mean that a pattern would evolve differently each time (unless the same fixed seed is used always). Might be unexpected, but also might be useful if the PRNG does minor tweaks that don't affect most patterns while still introducing some controlled nondeterminism.wirehead wrote: April 17th, 2024, 9:54 pm[...] There could be some more checks to ensure that the function is deterministic (disable random module, global variables, etc.) [...]
I agree that some explicit sigil character for "unbinding" would be useful in situations similar to the "catch-all" rule ("all other cells die or stay dead") visible at the end of many existing ruletables. It would be possible to writewirehead wrote: April 13th, 2024, 5:21 pm Because & is a common bitwise operator I think the sigil for unbinding a variable can be "?".
OTOH if you are making a rule where the states, or some subset of them more likely, cycles through sequentially, you could write "a, ?any, ?any, ?any, ..., (a+1)%N" to express this.
We're getting into very muddy waters here so I appreciate all feedback.
Code: Select all
var x: {0,1,2,3,4,5,6,7}
...
?x, ?x,?x,?x,?x,?x,?x,?x,?x, 0Code: Select all
var a: {1,2,3}
var b: {1,2,3}
0, a,b,a,b,a,b,a,b, 1Code: Select all
var a: {1,2,3}
0, ?a,?a,?a,?a,?a,?a,?a,?a, 1
Code: Select all
var a: {1,2,3}
0, a[1],a[2],a[1],a[2],a[1],a[2],a[1],a[2], 1Code: Select all
@RULE B-Univ
#State 1 is wire
#State 2 is turn right signal/command
#State 3 is signal tail, also emulates B2ae/S
#State 4 is turn left signal/command
#State 5 is the hand
#State 6 is retract signal/command
#State 7 is extend signal/command
@TABLE
n_states=8
neighborhood=Moore
symmetries=rotate4
var s:{2,4,6,7}
var s2:{4,6,7}
var s3:{2,6,7}
var s4:{2,4,7}
var s5:{2,4,6}
var ts:{2,4}
var a:{0,1,2,3,4,5,6,7}
var w:{0,1,3,5}
var b:{0,5}
var l:{0,3}
var h:{1,5}
0,1,0,1,0,0,0,0,0,1
0,5,1,*w,*w,*a,*a,*a,6,5
0,5,4,*a,*a,*a,*a,*a,*a,5
0,5,0,0,0,a,1,1,2,0
0,5,0,*a,*a,*a,*a,*a,2,5
0,1,3,2,5,0,0,0,0,0
0,*a,2,5,*a,*a,*a,*a,0,5
0,5,1,*a,*a,*a,*a,*a,6,5
0,6,5,0,0,0,0,0,5,1
0,6,5,*w,*w,*w,*w,*w,5,3
0,3,0,3,0,0,0,0,0,3
0,3,3,0,0,0,0,0,0,3
0,0,3,3,0,0,0,0,0,3
0,0,3,6,5,5,0,0,0,6
s,3,0,5,1,1,1,5,0,0
1,3,5,*w,*w,*w,*w,*w,5,0
3,5,0,5,*w,1,*w,5,0,0
5,0,1,0,0,0,0,0,0,0
5,0,3,1,1,0,0,1,0,0
5,s,3,h,0,0,0,a,1,5
5,s,3,5,*a,*a,*a,*a,1,5
5,5,*w,1,*w,0,0,6,0,3
5,0,5,3,1,*w,*w,*a,*a,0
5,*w,1,3,5,0,*a,*a,*w,0
5,0,3,ts,1,*w,*w,*w,*w,0
5,*w,1,ts,3,0,*w,*w,*w,0
5,0,3,7,1,*w,*w,*w,*w,0
5,*w,1,7,3,0,*w,*w,*w,0
5,1,0,5,*w,1,*w,5,0,1
5,0,6,5,0,w,0,0,0,0
5,0,5,6,0,1,0,0,0,6
3,*l,*l,*l,*l,*l,*l,*l,*l,0
5,5,*b,*b,*b,*b,*b,*b,*b,0
5,*b,5,*b,*b,*b,*b,*b,*b,0
5,ts,0,5,*a,0,*a,0,0,1
5,ts,0,0,*a,0,*a,5,0,1
5,5,s,*w,*w,*w,*w,*w,*w,5
1,0,5,s,0,0,0,w,0,1
1,s,0,0,0,0,0,5,0,s
1,s,0,0,0,*w,0,5,0,1
1,0,5,5,5,0,*a,0,*a,5
1,0,1,1,0,3,0,1,1,0
1,5,1,s,3,0,0,0,0,1
1,s,1,5,a,1,0,0,0,7
1,7,5,5,a,1,0,0,0,2
1,2,5,5,a,1,0,0,0,4
1,4,5,5,a,1,0,0,0,6
1,s,*w,*w,*a,*w,*a,*w,*w,s
3,1,*a,*a,5,6,5,*a,*a,5
6,s4,*w,*w,*w,3,*w,*w,*w,1
6,3,0,5,*a,1,*a,5,0,1
6,3,*w,*w,*w,5,*w,*w,*w,5
7,5,*a,*a,*a,*a,*a,*a,*a,3
s,1,*a,*a,*a,*a,*a,*a,*a,3
3,*a,*a,*a,*a,*a,*a,*a,*a,1
5,7,*a,*a,*a,*a,*a,*a,*a,7
5,6,*a,*a,*a,*a,*a,*a,*a,0
0,7,0,*a,*a,*a,*a,*a,0,5
6,0,*a,*a,*a,*a,*a,*a,*a,0
s,0,*a,*a,*a,*a,*a,*a,*a,1
@NAMES
0 dead
1 wire
2 RIGHT command
3 signal tail
4 LEFT command
5 hand
6 RETRACT command
7 EXTEND command
@COLORS
1 0 0 255
2 0 255 0
3 255 0 0
4 255 255 0
5 255 0 255
6 255 255 255
7 0 255 255Yes the already mentioned changes would allow to shorten many existing ruletables. I'm more interested in what would remain hard.
Well, if the rule is supposed to be random, then it's supposed to be random on every invocation of the rule function, which will totally break Hashlife. So if nondeterminism is allowed, then it will have to be run under an algorithm called "Naive" which does what you would expect (for every cell, evaluate the rule function), which would obviously be slow, especially if the rule is something mostly-deterministic-but-not-always (such as "B3/S23, but on each tick an Eater 1 has a 1% chance of dying"), and you're running a huge pattern.confocaloid wrote: April 18th, 2024, 5:19 am I think precomputing the rules using a PRNG wouldn't be a particularly serious problem. It would just mean that a pattern would evolve differently each time (unless the same fixed seed is used always). Might be unexpected, but also might be useful if the PRNG does minor tweaks that don't affect most patterns while still introducing some controlled nondeterminism.
Good point, I hand't thought about executing arbitrary code. You could setup Python/Lua to restrict network/filesystem access, etc, add a timeout (that triggers a KeyboardInterrupt after like 15 seconds). but then again, closing every possible hole is the reason that security bounty hunters have a job.confocaloid wrote: April 18th, 2024, 5:19 am The big problem would come with infinite loops, unbounded memory usage, filesystem access, and so on. You wouldn't want to have an infinite loop or a virus deleting all user files it can find, when the Golly user is trying to do something as simple as "File -> Open Pattern..."
I'm still going to side with squareroot12621 on this one: to a programmer, this looks more like array indexing.confocaloid wrote: April 18th, 2024, 5:19 am which would be a different rule (instead of 2 independent variables each used 4 times, one would have 8 independent variables each used 1 time).
To avoid declaring two variables with the same set of allowed values, one would need to have some "numbered sigils", which would be something equivalent toCode: Select all
var a: {1,2,3} 0, a[1],a[2],a[1],a[2],a[1],a[2],a[1],a[2], 1
If the aim is to construct a ruletable programmatically and write it to a separate file, then a Golly script (Lua/Python) can already do that.wirehead wrote: April 18th, 2024, 9:23 pm You could try to limit calls to the code to speed it up by "compiling" the ruletable once and automatically adding a tree to the file with the code in it (same sort of operation as the existing "clean up old rules"), but it would still have to be run to do that, so fair concern.
It's good if the syntax looks like array indexing. Because it's meant to look like an array of variables, all of the same type and with the same set of allowed values.wirehead wrote: April 18th, 2024, 9:23 pm I'm still going to side with squareroot12621 on this one: to a programmer, this looks more like array indexing.
I think angle brackets would be unnecessarily hard to read and write. With some additional assumptions about future syntax, imagine rules like these:wirehead wrote: April 18th, 2024, 9:23 pm For this kind of functionality, using angle brackets (so a<1>, a<2>, etc.) seems more like an intuitive solution (the <> syntax usually means "instantiate a template" in languages that support it such as C++ and Java).
Code: Select all
0, a<1>, a<2>, 0, 0, 0, 0, 0, 0, a<1> if a<1> < a<2> else a<2>
0, b<1>, b<2>, b<3>, 0, 0, 0, 0, 0, b<1> if b<1> > b<2> and b<2> > b<3> else b<3>Code: Select all
0, a[1], a[2], 0, 0, 0, 0, 0, 0, a[1] if a[1] < a[2] else a[2]
0, b[1], b[2], b[3], 0, 0, 0, 0, 0, b[1] if b[1] > b[2] and b[2] > b[3] else b[3]I wouldn't say so—if a were defined to be {1, 3, 5, 7}, a[1] looks like it could only be equal to 1 (or 3 if you're a true programmer). In actuality, though, it could work as any element of a. These two views aren't the same.confocaloid wrote: April 18th, 2024, 10:46 pmIt's good if the syntax looks like array indexing. Because it's meant to look like an array of variables, all of the same type and with the same set of allowed values.wirehead wrote: April 18th, 2024, 9:23 pm I'm still going to side with squareroot12621 on this one: to a programmer, this looks more like array indexing.
I do agree that angle brackets are not the most optimal solution. I propose a#1 instead, which doesn't clash with any symbols that would actually be useful in a ruletable, and clearly states "copy #1 of a".confocaloid wrote: April 18th, 2024, 10:46 pmI think angle brackets would be unnecessarily hard to read and write. With some additional assumptions about future syntax, imagine rules like these:wirehead wrote: April 18th, 2024, 9:23 pm For this kind of functionality, using angle brackets (so a<1>, a<2>, etc.) seems more like an intuitive solution (the <> syntax usually means "instantiate a template" in languages that support it such as C++ and Java).Currently I can't tell whether I will end up implementing some alternative syntax for ruletables, but if that happens, I'll definitely use square brackets. Rules like this would be much easier to read and write:Code: Select all
0, a<1>, a<2>, 0, 0, 0, 0, 0, 0, a<1> if a<1> < a<2> else a<2> 0, b<1>, b<2>, b<3>, 0, 0, 0, 0, 0, b<1> if b<1> > b<2> and b<2> > b<3> else b<3>Code: Select all
0, a[1], a[2], 0, 0, 0, 0, 0, 0, a[1] if a[1] < a[2] else a[2] 0, b[1], b[2], b[3], 0, 0, 0, 0, 0, b[1] if b[1] > b[2] and b[2] > b[3] else b[3]
"If a were defined to be {1, 3, 5, 7}" -- how do you do that in a ruletable, exactly?squareroot12621 wrote: April 19th, 2024, 9:58 pmI wouldn't say so—if a were defined to be {1, 3, 5, 7}, a[1] looks like it could only be equal to 1 (or 3 if you're a true programmer). In actuality, though, it could work as any element of a. These two views aren't the same.confocaloid wrote: April 18th, 2024, 10:46 pm[...]
It's good if the syntax looks like array indexing. Because it's meant to look like an array of variables, all of the same type and with the same set of allowed values.
Code: Select all
var a = {1, 3, 5, 7}
0, a, a, a, 0, 0, 0, 0, 0, 4Code: Select all
0, 1, 1, 1, 0, 0, 0, 0, 0, 4
0, 3, 3, 3, 0, 0, 0, 0, 0, 4
0, 5, 5, 5, 0, 0, 0, 0, 0, 4
0, 7, 7, 7, 0, 0, 0, 0, 0, 4I fail to see any significant danger of confusion in this pseudocode (which I think can become an actual syntax as written):squareroot12621 wrote: April 19th, 2024, 9:58 pm (For even more confusion, try a[1] and a[2] together.)
Code: Select all
var a : {1, 3, 5, 7} # the variable a can take values from the set {1, 3, 5, 7}
0, a[1], a[1], a[1], 0, 0, 0, 0, 0, a[1] # if there are three alive neighbours all the same cellstate, then the middle cell is born with the same cellstate
0, a[1], a[2], a[2], 0, 0, 0, 0, 0, a[2] # if there are three alive neighbours with two distinct cellstates, then the middle cell is born with the majority cellstate
0, a[1], a[2], a[3], 0, 0, 0, 0, 0, 16 - a[1] - a[2] - a[3] # if there are three alive neighbours all pairwise distinct, then the middle cell is born with the fourth unused cellstate
"#" will not work, because it will obviously clash with comments which extend from the first "#" to the end of line.squareroot12621 wrote: April 19th, 2024, 9:58 pm I do agree that angle brackets are not the most optimal solution. I propose a#1 instead, which doesn't clash with any symbols that would actually be useful in a ruletable, and clearly states "copy #1 of a".