Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/elementary-cellular-automaton.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / elementary-cellular-automaton.wiki` 111 lines ยท 2239 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text sp " " 8 text minus "-" 9 text trule "rule " 10 text tdot "." 11 text thash "#" 12 global cur uchar 32 13 global nxt uchar 32 14 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 15 fn emit a view uchar * to void 16 o = ulong 0 17 while lt o len a bound 4096 18 k = write 1 a o sub len a o 19 if le k 0 20 exit 1 21 end 22 o = add o ulong k 23 end 24 end 25 note emitu writes n in decimal; 20 digits hold every ulong 26 fn emitu n ulong to void 27 d = new uchar 20 0 28 i = ulong 20 29 v = n 30 while true bound 20 31 i = sub i 1 32 put d i uchar add rem v 10 48 33 v = div v 10 34 if eq v 0 35 break 36 end 37 end 38 emit part d i sub 20 i 39 end 40 note 31 cells on a ring; a cell's next state is bit (4*left + 2*self + right) of the rule number 41 fn line to void 42 for i ulong 31 43 if eq get cur i 1 44 emit thash 45 else 46 emit tdot 47 end 48 end 49 emit nl 50 end 51 fn step rule ulong to void 52 for i ulong 31 53 l = ulong get cur rem add i 30 31 54 c = ulong get cur i 55 r = ulong get cur rem add i 1 31 56 k = add add mul l 4 mul c 2 r 57 put nxt i uchar and shr rule k 1 58 end 59 for i ulong 31 60 put cur i get nxt i 61 end 62 end 63 fn run rule ulong to void 64 emit trule 65 emitu rule 66 emit nl 67 for i ulong 31 68 put cur i 0 69 end 70 put cur 15 1 71 for g ulong 16 72 line 73 step rule 74 end 75 end 76 fn main to int 77 run 90 78 emit nl 79 run 30 80 emit nl 81 run 110 82 ret 0 83 end 84 85 {{out}} 86

87 rule 90

88 ...............#...............

89 ..............#.#..............

90 .............#...#.............

91 ............#.#.#.#............

92 ...........#.......#...........

93 ..........#.#.....#.#..........

94 .........#...#...#...#.........

95 ........#.#.#.#.#.#.#.#........

96 .......#...............#.......

97 ......#.#.............#.#......

98 .....#...#...........#...#.....

99 ....#.#.#.#.........#.#.#.#....

100 ...#.......#.......#.......#...

101 ..#.#.....#.#.....#.#.....#.#..

102 ...

103 .......#######.#...............

104 ......##.....###...............

105 .....###....##.#...............

106 ....##.#...#####...............

107 ...#####..##...#...............

108 ..##...#.###..##...............

109 .###..####.#.###...............

110 ##.#.##..#####.#...............

111