From: Amélia Coutard-Sander Date: Wed, 7 Jan 2026 13:38:51 +0000 (+0100) Subject: Définition de la signature des automates X-Git-Url: https://git.f4mnq.fr/?a=commitdiff_plain;h=2a7f0f1527c95978310dc89d0623e50e66512c28;p=cells.git Définition de la signature des automates --- diff --git a/automata/automata.ml b/automata/automata.ml index 3fbe032..3183f53 100644 --- a/automata/automata.ml +++ b/automata/automata.ml @@ -12,3 +12,23 @@ * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *) + +module type Automaton = sig + val name : string + + type t + + val neighbours : (int * int) list + + val transition : t list -> t -> t + + val default : t + + val prev : t -> t + + val next : t -> t + + val color : t -> Graphics.color +end + +let automata = [] diff --git a/automata/automata.mli b/automata/automata.mli index 3fbe032..4b12998 100644 --- a/automata/automata.mli +++ b/automata/automata.mli @@ -12,3 +12,23 @@ * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *) + +module type Automaton = sig + val name : string + + type t + + val neighbours : (int * int) list + + val transition : t list -> t -> t + + val default : t + + val prev : t -> t + + val next : t -> t + + val color : t -> Graphics.color +end + +val automata : (module Automaton) list diff --git a/automata/dune b/automata/dune index 07028bf..c503e3a 100644 --- a/automata/dune +++ b/automata/dune @@ -1,2 +1,5 @@ +(include_subdirs unqualified) + (library - (name automata)) + (name automata) + (libraries graphics)) diff --git a/bin/dune b/bin/dune index 3909b04..6313089 100644 --- a/bin/dune +++ b/bin/dune @@ -1,4 +1,4 @@ (executable (public_name cells) (name main) - (libraries automata)) + (libraries automata graphics)) diff --git a/bin/main.ml b/bin/main.ml index d2fb530..f79aac1 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -13,4 +13,9 @@ * with this program. If not, see . *) -let () = Printf.printf "Hello, world !\n" +let () = + List.iter + (fun m -> + let module Automaton = (val m : Automata.Automaton) in + Printf.printf "%s\n" Automaton.name) + Automata.automata diff --git a/dune-project b/dune-project index 950fc33..68b953c 100644 --- a/dune-project +++ b/dune-project @@ -18,5 +18,5 @@ (name cells) (synopsis "Un simulateur d'automates cellulaires.") (description "Un système pour simuler n'importe quel automate cellulaire en deux dimensions (à condition d'en faire un module OCaml).") - (depends ocaml dune) + (depends ocaml dune graphics) (tags ("cellular" "automaton" "automata")))