From b0462b8f29ca158f4d600fb63bbeb82b5ffa744a Mon Sep 17 00:00:00 2001
From: =?utf8?q?Am=C3=A9lia=20Coutard-Sander?= <git@ameliathe1st.gay>
Date: Fri, 13 Dec 2024 18:04:22 +0100
Subject: [PATCH] =?utf8?q?Ajout=20d'un=20automate=20de=20g=C3=A9n=C3=A9rat?=
 =?utf8?q?ion=20de=20labyrinthe?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

---
 automata/automata.ml      |  1 +
 automata/automata/maze.ml | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 automata/automata/maze.ml

diff --git a/automata/automata.ml b/automata/automata.ml
index e8a665f..47189dd 100644
--- a/automata/automata.ml
+++ b/automata/automata.ml
@@ -61,4 +61,5 @@ let automata =
           (module Wireworld : Automaton);
           (module Brain : Automaton);
           (module Cont : Automaton);
+          (module Maze : Automaton);
         ]
diff --git a/automata/automata/maze.ml b/automata/automata/maze.ml
new file mode 100644
index 0000000..402d982
--- /dev/null
+++ b/automata/automata/maze.ml
@@ -0,0 +1,38 @@
+(* 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 = "Labyrinthe B3S12345"
+
+type t = Sol | Mur
+
+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 (( = ) Mur) l) in
+        if n < 1 || n > 5 then Sol else if n == 3 then Mur else c
+
+let default = Sol
+
+let prev = function
+        | Sol -> Mur
+        | Mur -> Sol
+
+let next = function
+        | Sol -> Mur
+        | Mur -> Sol
+
+let color = function
+        | Sol -> ('\x00', '\x00', '\x1F')
+        | Mur -> ('\xFF', '\xFF', '\xFF')
-- 
2.46.0