From: Amélia Coutard-Sander Date: Fri, 13 Dec 2024 13:11:27 +0000 (+0100) Subject: Ajout d'un automate continu, pour tester X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=fe9a5412e47c358707a533548d4ec1548b9b680b;p=cells.git Ajout d'un automate continu, pour tester --- diff --git a/automata/automata.ml b/automata/automata.ml index f7f044b..968298a 100644 --- a/automata/automata.ml +++ b/automata/automata.ml @@ -49,4 +49,10 @@ let update (type t) (m : (module Automaton with type t = t)) ((d, cells) as boar Array.init 64 (fun y -> M.transition (List.map (fun (dx, dy) -> get (x + dx) (y + dy) board) M.neighbours) cells.(x).(y))) ) -let automata = [(module Life : Automaton); (module Wireworld : Automaton); (module Brain : Automaton)] +let automata = + [ + (module Life : Automaton); + (module Wireworld : Automaton); + (module Brain : Automaton); + (module Cont : Automaton); + ] diff --git a/automata/automata/cont.ml b/automata/automata/cont.ml new file mode 100644 index 0000000..88496ec --- /dev/null +++ b/automata/automata/cont.ml @@ -0,0 +1,32 @@ +(* 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 = "Automate continu random" + +type t = float + +let neighbours = [(-1, 0); (0, -1); (0, 1); (1, 0)] + +let transition l c = List.fold_left ( +. ) c l /. 5. + +let default = 0. + +let prev c = c -. 1. + +let next c = c +. 1. + +let color c = + let v = 256. /. (1. +. Float.exp (-.c)) |> int_of_float |> char_of_int in + (v, v, v)