From: Amélia Coutard-Sander Date: Fri, 13 Dec 2024 17:04:22 +0000 (+0100) Subject: Ajout d'un automate de génération de labyrinthe X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=b0462b8f29ca158f4d600fb63bbeb82b5ffa744a;p=cells.git Ajout d'un automate de génération de labyrinthe --- 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 . + * + * 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 . + *) + +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')