From: Amélia Coutard-Sander <git@ameliathe1st.gay>
Date: Thu, 12 Dec 2024 15:17:24 +0000 (+0100)
Subject: Définition de la signature des automates
X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=29b64f853a8f4b2af9e127f861d4aea7babdba49;p=cells.git

Définition de la signature des automates
---

diff --git a/automata/automata.ml b/automata/automata.ml
index e090318..63de763 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 <https://www.gnu.org/licenses/>.
  *)
+
+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 e090318..59a2c62 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 <https://www.gnu.org/licenses/>.
  *)
+
+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 42c62ee..350e3d0 100644
--- a/bin/main.ml
+++ b/bin/main.ml
@@ -13,4 +13,9 @@
  * with this program. If not, see <https://www.gnu.org/licenses/>.
  *)
 
-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 22574f6..c612ef9 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")))