( ************** allbutns.rule ) : allbutns n.east n.west s.east s.west east west + + + + + 3 = center' xor >pln0 ; : :ALLBUTNS n/marg rule: allbutns ; ( ************** anneal.rule ) : anneal 9sum { 0 0 0 0 1 0 1 1 1 1 } >pln0 ; : :ANNEAL n/moore rule: anneal ; ( ************** bank.rule ) \ Bank's computer (p. 42) : corner? north south = if u else 0 then ; : banks north south west east + + + { u u corner? 1 1 } >pln0 echo ; : :BANKS n/moore rule: banks ; ( ************** bball.rule ) : same center >pln0 ; : reflect opp >pln0 ; : turn center opp and if 0 >pln0 else cw ccw and if 1 >pln0 else same then then ; : bball center cw ccw opp + + + { same reflect turn same same } ; : :BBALL n/marg rule: bball ; ( ************** cball.rule ) : cball center' opp' cw' ccw' or or or if center >pln0 center' center or >pln1 else bball center' >pln1 then ; : :CBALL n/marg rule: cball ; : tcball cball center >pln3 center' >pln4 center center' xor >pln6 ; : :TCBALL n/marg rule: tcball ; ( ************** critters.rule ) : -center center 1 xor ; : -opp opp 1 xor ; : critters center opp cw ccw + + + { -center -center center -opp -center } >pln0 ; : :CRITTERS n/marg rule: critters ; : critters* center opp cw ccw + + + { -center -opp center -center -center } >pln0 ; : :CRITTERS* n/marg rule: critters* ; ( ************** wavers.rule ) : -center center 1 xor ; : -opp opp 1 xor ; : wavers center opp cw ccw + + + { -center -center center -center -opp } >pln0 ; : :WAVERS n/marg rule: wavers ; : wavers* center opp cw ccw + + + { -opp -center center -center -center } >pln0 ; : :WAVERS* n/marg rule: wavers* ; ( ************** tron.rule ) : tron center cw ccw opp + + + { 1 u u u 0 } >pln0 center >pln1 center' >pln2 center center' xor >pln6 ; : :TRON n/marg rule: tron ; ( ************** logic.rule ) : #wires ( --- 0..4 ) center' cw' ccw' opp' + + + ; : signals opp' if opp then cw' if cw then ccw' if ccw then ; : controls opp' 0= if opp then cw' 0= if cw then ccw' 0= if ccw then ; : 1wire ( -- 0|1 ) opp cw ccw or or ; : 2wire ( -- 0|1 ) signals cw' ccw' or if opp xor then ; : 3wire ( -- 0|1 ) controls if signals and else signals or then ; : logic center' if #wires { 0 1wire 2wire 3wire opp } else center then >pln0 center' >pln1 ; : :LOGIC n/marg rule: logic ; ( ************** black.rule ) : black-rule 1 >pln0 1 >pln1 ; : :BLACK n/moore rule: black-rule ; ( ************** white.rule ) : white-rule 0 >pln0 0 >pln1 ; : :WHITE n/moore rule: white-rule ; ( ************** bonks.rule ) \ Bank's computer (p. 42) : corner? north south = if u else 0 then ; : yow center north xor ; : bonks north south west east + + + center' + 3 and { u u corner? 1 1 yow } >pln0 echo ; : :BONKS n/moore rule: banks ; ( ************** brain.rule ) : ready centers { 1 0 0 0 } ; : stimulus 8sum { 0 0 1 0 0 0 0 0 0 0 } ; : brian's-brain stimulus ready and >pln0 trippy-echo ; : :BRAIN n/moore rule: brian's-brain ; ( ************** discharge.rule ) : zing n.east s.east n.west s.west center + + + + ; : zoing north south east west xor xor xor ; : eh zing zoing xor if zing else 0 then ; : discharge eh >pln0 ; : :DISCHARGE n/moore rule: discharge ; ( ************** frob.rule ) : nsum north south east west n.west n.east s.west s.east center + + + + + + + + ; : mumble nsum { 0 north 0 0 south 0 1 1 1 1 } ; : frob mumble center' xor 1 = if 1 else 0 then >pln0 ; : :FROB n/moore rule: frob ; ( ************** greenberg.rule ) : ready centers { 1 0 0 0 } ; : greenberg center north south west east or or or or ready and >pln0 ; : :GREENBERG n/moore rule: greenberg ; ( ************** h3.rule ) : h3 north south east west n.east s.west + + + + + 3 = center' xor >pln0 ; : :H3 n/moore rule: h3 ; ( ************** histogram.rule ) : take? center 0= north 0> and ; : give? south 0= center 0> and ; : safe-pass center take? if drop north then give? if drop south then >pln0 center' >pln1 ; : histogram safe-pass echo ; : :HISTOGRAM n/moore rule: histogram ; ( ************** gglass.rule ) : gglass west 2* east + 2* north + 2* south + 2* center + { 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 } >pln0 center >pln1 ; : :GGLASS n/moore rule: gglass ; ( ************** hglass.rule ) : hglass east 2* west + 2* south + 2* north + 2* center + { 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 } >pln0 center >pln1 ; : :HGLASS n/moore rule: hglass ; ( ************** iglass.rule ) : iglass north 2* south + 2* east + 2* west + 2* center + { 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 } >pln0 center >pln1 ; : :IGLASS n/moore rule: iglass ; ( ************** jglass.rule ) : jglass south 2* north + 2* west + 2* east + 2* center + { 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 } >pln0 center >pln1 ; : :JGLASS n/moore rule: jglass ; ( ************** higlass.rule ) : hglass0 east 2* west + 2* south + 2* north + 2* center + { 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 } >pln0 ; : iglass1 north' 2* south' + 2* east' + 2* west' + 2* center' + { 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 } >pln1 ; : higlass hglass0 iglass1 center >pln2 center' >pln3 1 >pln6 ; : :HIGLASS n/vonn rule: higlass ; ( ************** lichens.rule ) : lichens-with-death 8sum { u u u 1 0 u u 1 1 } >pln0 ; : lichens lichens-with-death echo ; : :LICHENS n/moore rule: lichens ; ( ************** life.rule ) : life center 0= if 8sum { 0 0 0 1 0 0 0 0 0 } else 8sum { 0 0 1 1 0 0 0 0 0 } then >pln0 echo ; : :LIFE n/moore rule: life ; ( ************** nerds.rule ) : nerds north south + west + east + center + dup 5 = swap 0= or not center' xor >pln0 echo ; : :NERDS n/moore rule: nerds ; ( ************** noop.rule ) : noop-rule center >pln0 center' >pln1 ; : :NOOP n/moore rule: noop-rule ; ( ************** parity.rule ) : parity center north south west east xor xor xor xor >pln0 trippy-echo ; : :PARITY n/moore rule: parity ; ( ************** rugs.rule ) : rugs \ north south east west n.east s.west + + + + + 3 = center' north south east west center xor xor xor xor >pln0 ; : :RUGS n/moore rule: rugs ; ( ************** rugs1.rule ) : rugs1 center >pln0 north' south' east' west' center' xor xor xor xor >pln1 ; : :RUGS1 n/moore rule: rugs1 ; ( ************** scramble.rule ) : 1xor 1 xor ; : scramble north 1xor east 1xor + south 1xor + west + dup 1 = swap 2 = or center' xor >pln0 ; : :SCRAMBLE n/moore rule: scramble ; ( ************** serif.rule ) : serif center if 1 else north south east west n.east n.west s.east s.west + + + + + + + 7 - if 0 else north if n.east n.west xor else south if s.east s.west xor else east if n.east s.east xor else west if n.west s.west xor else west then then then then then then >pln0 ; : :SERIF n/moore rule: serif ; ( ************** sim.rule ) : zing n.east s.west xor n.west s.east xor + ; : zoing north south east west + + + ; : sim zing { 0 1 zoing } >pln0 ; : :SIM n/moore rule: sim ; ( ************** slime-tunnel.rule ) : slime-tunnel center north south west east 1 + + + + + { 0 1 1 1 1 0 1 } center' xor >pln0 echo ; : :SLIME-TUNNEL n/moore rule: slime-tunnel ; ( ************** soil.rule ) : stable n.west north n.east or or s.west south s.east or or n.west west s.east or or n.east east s.east or or and and and ; : soil center stable and >pln0 ; : :SOIL n/moore rule: soil ; ( ************** stripes.rule ) : zot s.west s.east center + + ; : zing zot 2 < if 1 else 0 then >pln0 ; : :STRIPES n/moore rule: zing ; ( ************** swap.rule ) : swap-rule center >pln1 center' >pln0 ; : :SWAP n/moore rule: swap-rule ; ( ************** time-tunnel.rule ) : time-tunnel center north south west east + + + + { 0 1 1 1 1 0 } center' xor >pln0 echo ; : :TIME-TUNNEL n/moore rule: time-tunnel ; ( ************** traffic.rule ) : zing n.east s.east n.west s.west center + + + + ; : zoing north south east west xor xor xor ; : traffic zing 2 > if zoing else 1 then >pln0 ; : :TRAFFIC n/moore rule: traffic ; ( ************** worms.rule ) \ tube worms (p. 82) : alarm 8sum { 0 0 1 1 1 1 1 1 1 } ; : tube-worms ¢ers { 1 0 0 0 } >pln0 alarm >pln1 ; : timer center center' and if 3 else ¢ers { 0 0 1 2 } then >plnb ; : worms tube-worms timer ; : :WORMS n/moore-ab rule: worms ; ( ************** worms2.rule ) \ tube worms (p. 82) : alarm 8sum { 0 0 0 1 1 1 1 1 1 } ; : tube-worms ¢ers { 1 0 0 0 } >pln0 alarm >pln1 ; : timer center center' and if 3 else ¢ers { 0 0 1 2 } then >plnb ; : worms2 tube-worms timer ; : :WORMS2 n/moore-ab rule: worms2 ; ( ************** worms3.rule ) \ tube worms (p. 82) : alarm 8sum { 0 0 1 0 1 1 1 1 1 } ; : tube-worms ¢ers { 1 0 0 0 } >pln0 alarm >pln1 ; : timer center center' and if 3 else ¢ers { 0 0 1 2 } then >plnb ; : worms3 tube-worms timer ; : :WORMS3 n/moore-ab rule: worms3 ; ( ************** x2.rule ) : x2 n.east n.west s.east s.west + + + 2 = center' xor >pln0 echo ; : :X2 n/moore rule: x2 ; ( ************** hoglass.rule ) : hoglass center' if east 2* west + 2* south + 2* north + 2* center + { 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 } >pln0 else north 2* south + 2* east + 2* west + 2* center + { 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 } >pln0 then center' >pln1 ; : :HOGLASS n/vonn rule: hoglass ; ( ************** up.rule ) : up south >pln0 south' >pln1 ; : :UP n/vonn rule: up ; ( ************** down.rule ) : down north >pln0 north' >pln1 ; : :DOWN n/vonn rule: down ; ( ************** right.rule ) : right west >pln0 west' >pln1 ; : :RIGHT n/vonn rule: right ; ( ************** left.rule ) : left east >pln0 east' >pln1 ; : :LEFT n/vonn rule: left ; ( ************** heat.rule ) : :HEAT n/heat ; : :DHEAT n/dheat ; : :LHEAT n/lheat ; : :LDHEAT n/ldheat ;