--- /dev/null
+(* Copyright 2024 Amélia COUTARD <https://www.ameliathe1st.gay>.
+ *
+ * This file from the program cells is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License along
+ * with this program. If not, see <https://www.gnu.org/licenses/>.
+ *)
+
+let name = "life"
+
+type t = Dead | Alive
+
+let neighbours = [(-1, -1); (-1, 0); (-1, 1); (0, -1); (0, 1); (1, -1); (1, 0); (1, 1)]
+
+let transition l c =
+ let n = List.length (List.filter (( = ) Alive) l) in
+ if n <= 2 || n >= 4 then Dead else if n == 3 then Alive else c
+
+let default = Dead
+
+let prev = function
+ | Dead -> Alive
+ | Alive -> Dead
+
+let next = function
+ | Dead -> Alive
+ | Alive -> Dead
+
+let color = function
+ | Dead -> Graphics.rgb 0 0 31
+ | Alive -> Graphics.rgb 255 255 255
--- /dev/null
+(* Copyright 2024 Amélia COUTARD <https://www.ameliathe1st.gay>.
+ *
+ * This file from the program cells is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License along
+ * with this program. If not, see <https://www.gnu.org/licenses/>.
+ *)
+
+let name = "wireworld"
+
+type t = Empty | Conductor | Head | Tail
+
+let neighbours = [(-1, -1); (-1, 0); (-1, 1); (0, -1); (0, 1); (1, -1); (1, 0); (1, 1)]
+
+let transition l = function
+ | Empty -> Empty
+ | Conductor ->
+ let n = List.length (List.filter (( = ) Head) l) in
+ if n = 1 || n = 2 then Head else Conductor
+ | Head -> Tail
+ | Tail -> Conductor
+
+let default = Empty
+
+let prev = function
+ | Empty -> Tail
+ | Conductor -> Empty
+ | Head -> Conductor
+ | Tail -> Head
+
+let next = function
+ | Empty -> Conductor
+ | Conductor -> Head
+ | Head -> Tail
+ | Tail -> Empty
+
+let color = function
+ | Empty -> Graphics.rgb 0 0 31
+ | Conductor -> Graphics.rgb 191 191 0
+ | Head -> Graphics.rgb 191 0 0
+ | Tail -> Graphics.rgb 0 0 191