From: Amélia Coutard-Sander <git@ameliathe1st.gay>
Date: Sun, 12 Jan 2025 02:16:17 +0000 (+0100)
Subject: Sérialisation des lignes en vraies lignes
X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=0969607b001f60517c3811ebc09a0f038cb9d04f;p=cells.git

Sérialisation des lignes en vraies lignes
---

diff --git a/automata/automata.ml b/automata/automata.ml
index ca931d1..5439adf 100644
--- a/automata/automata.ml
+++ b/automata/automata.ml
@@ -133,10 +133,8 @@ let deserialise (type t) (m : (module Automaton with type t = t)) channel =
                                 and y = In_channel.input_line channel |> Option.get |> int_of_string in
                                 let chunk =
                                         Array.init chunk_size (fun _ ->
-                                            Array.init chunk_size (fun _ ->
-                                                (In_channel.input_line channel |> Option.get).[0]
-                                                |> M.of_char
-                                                |> Option.get))
+                                            let l = In_channel.input_line channel |> Option.get in
+                                            Array.init chunk_size (fun i -> l.[i] |> M.of_char |> Option.get))
                                 in
                                 aux (CoordMap.add (x, y) chunk board)
                 in
@@ -150,7 +148,11 @@ let serialise (type t) (m : (module Automaton with type t = t)) (d, board) chann
         CoordMap.iter
           (fun (x, y) chunk ->
             Printf.fprintf channel "%d\n%d\n" x y;
-            Array.iter (Array.iter (fun c -> Printf.fprintf channel "%c\n" (M.to_char c))) chunk)
+            Array.iter
+              (fun l ->
+                Array.iter (fun c -> Printf.fprintf channel "%c" (M.to_char c)) l;
+                Printf.fprintf channel "\n")
+              chunk)
           board
 
 let automata =