• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbarbin / super-master-mind / 217

31 Jan 2026 12:24PM UTC coverage: 50.206% (-38.1%) from 88.313%
217

Pull #45

github

web-flow
Merge 235b668da into 3d48eb3d9
Pull Request #45: Dune pkg ci migration

610 of 1215 relevant lines covered (50.21%)

597078.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/test/expect/test__example.ml
1
(*********************************************************************************)
2
(*  super-master-mind: A solver for the super master mind game                   *)
3
(*  SPDX-FileCopyrightText: 2021-2025 Mathieu Barbin <mathieu.barbin@gmail.com>  *)
4
(*  SPDX-License-Identifier: MIT                                                 *)
5
(*********************************************************************************)
6

7
let verify_steps (ts : Guess.t list) = ignore (ts : Guess.t list)
×
8
let with_task_pool ~f = Task_pool.with_t (Task_pool.Config.default ()) ~f
×
9

10
let%expect_test "1" =
11
  verify_steps
×
12
    (with_task_pool ~f:(fun ~task_pool ->
13
       Example.solve
×
14
         ~task_pool
15
         ~color_permutation:Color_permutation.identity
16
         ~solution:(Code.create_exn [| Green; Blue; Orange; White; Red |])));
×
17
  [%expect
×
18
    {|
19
    (1,
20
     { candidate = [| Black;  Blue;  Brown;  Green;  Orange |]
21
     ; expected_bits_gained = 3.2315534058614328
22
     ; expected_bits_remaining = 11.768446594138567
23
     ; min_bits_gained = 2.212505500303239
24
     ; max_bits_gained = 15.
25
     ; max_bits_remaining = 12.787494499696761
26
     ; by_cue =
27
         [ { cue = { white = 2; black = 1 }
28
           ; size_remaining = 4680
29
           ; bits_remaining = 12.192292814470767
30
           ; bits_gained = 2.8077071855292335
31
           ; probability = 0.142822265625
32
           ; next_best_guesses = Not_computed
33
           }
34
         ]
35
     })
36
    (2,
37
     { candidate = [| Black;  Blue;  Orange;  Orange;  Yellow |]
38
     ; expected_bits_gained = 3.2916088087636
39
     ; expected_bits_remaining = 8.9006840057071663
40
     ; min_bits_gained = 2.3374244312105308
41
     ; max_bits_gained = 10.192292814470767
42
     ; max_bits_remaining = 9.8548683832602357
43
     ; by_cue =
44
         [ { cue = { white = 0; black = 2 }
45
           ; size_remaining = 280
46
           ; bits_remaining = 8.1292830169449672
47
           ; bits_gained = 4.0630097975257993
48
           ; probability = 0.059829059829059832
49
           ; next_best_guesses = Not_computed
50
           }
51
         ]
52
     })
53
    (3,
54
     { candidate = [| Black;  Green;  Orange;  Red;  White |]
55
     ; expected_bits_gained = 3.7249049284531512
56
     ; expected_bits_remaining = 4.404378088491816
57
     ; min_bits_gained = 2.8073549220576046
58
     ; max_bits_gained = 8.1292830169449672
59
     ; max_bits_remaining = 5.3219280948873626
60
     ; by_cue =
61
         [ { cue = { white = 3; black = 1 }
62
           ; size_remaining = 19
63
           ; bits_remaining = 4.2479275134435852
64
           ; bits_gained = 3.881355503501382
65
           ; probability = 0.067857142857142852
66
           ; next_best_guesses = Not_computed
67
           }
68
         ]
69
     })
70
    (4,
71
     { candidate = [| Black;  Black;  Red;  Orange;  Green |]
72
     ; expected_bits_gained = 3.2210972500579564
73
     ; expected_bits_remaining = 1.0268302633856288
74
     ; min_bits_gained = 2.6629650127224291
75
     ; max_bits_gained = 4.2479275134435852
76
     ; max_bits_remaining = 1.5849625007211561
77
     ; by_cue =
78
         [ { cue = { white = 3; black = 0 }
79
           ; size_remaining = 1
80
           ; bits_remaining = 0.
81
           ; bits_gained = 4.2479275134435852
82
           ; probability = 0.052631578947368418
83
           ; next_best_guesses = Not_computed
84
           }
85
         ]
86
     })
87
    (5,
88
     { candidate = [| Green;  Blue;  Orange;  White;  Red |]
89
     ; expected_bits_gained = 0.
90
     ; expected_bits_remaining = 0.
91
     ; min_bits_gained = 0.
92
     ; max_bits_gained = 0.
93
     ; max_bits_remaining = 0.
94
     ; by_cue =
95
         [ { cue = { white = 0; black = 5 }
96
           ; size_remaining = 1
97
           ; bits_remaining = 0.
98
           ; bits_gained = 0.
99
           ; probability = 1.
100
           ; next_best_guesses = Not_computed
101
           }
102
         ]
103
     })
104
    |}]
×
105
;;
106

107
let%expect_test "2" =
108
  verify_steps
×
109
    (with_task_pool ~f:(fun ~task_pool ->
110
       Example.solve
×
111
         ~task_pool
112
         ~color_permutation:(lazy (Color_permutation.of_index_exn 40319))
×
113
         ~solution:(Code.create_exn [| Green; Blue; Orange; White; Red |])));
×
114
  [%expect
×
115
    {|
116
    (1,
117
     { candidate = [| Yellow;  White;  Red;  Orange;  Green |]
118
     ; expected_bits_gained = 3.2315534058614328
119
     ; expected_bits_remaining = 11.768446594138567
120
     ; min_bits_gained = 2.212505500303239
121
     ; max_bits_gained = 15.
122
     ; max_bits_remaining = 12.787494499696761
123
     ; by_cue =
124
         [ { cue = { white = 4; black = 0 }
125
           ; size_remaining = 1215
126
           ; bits_remaining = 10.246740598493144
127
           ; bits_gained = 4.7532594015068561
128
           ; probability = 0.037078857421875
129
           ; next_best_guesses = Not_computed
130
           }
131
         ]
132
     })
133
    (2,
134
     { candidate = [| White;  Yellow;  Green;  Green;  Black |]
135
     ; expected_bits_gained = 3.0838519191797964
136
     ; expected_bits_remaining = 7.1628886793133475
137
     ; min_bits_gained = 2.4012505475487691
138
     ; max_bits_gained = 8.2467405984931439
139
     ; max_bits_remaining = 7.8454900509443748
140
     ; by_cue =
141
         [ { cue = { white = 2; black = 0 }
142
           ; size_remaining = 228
143
           ; bits_remaining = 7.8328900141647413
144
           ; bits_gained = 2.4138505843284026
145
           ; probability = 0.18765432098765433
146
           ; next_best_guesses = Not_computed
147
           }
148
         ]
149
     })
150
    (3,
151
     { candidate = [| Orange;  Blue;  Yellow;  Red;  White |]
152
     ; expected_bits_gained = 3.3377676472031377
153
     ; expected_bits_remaining = 4.4951223669616036
154
     ; min_bits_gained = 2.5109619192773787
155
     ; max_bits_gained = 7.8328900141647413
156
     ; max_bits_remaining = 5.3219280948873626
157
     ; by_cue =
158
         [ { cue = { white = 3; black = 1 }
159
           ; size_remaining = 40
160
           ; bits_remaining = 5.3219280948873626
161
           ; bits_gained = 2.5109619192773787
162
           ; probability = 0.17543859649122806
163
           ; next_best_guesses = Not_computed
164
           }
165
         ]
166
     })
167
    (4,
168
     { candidate = [| Orange;  Brown;  White;  Yellow;  Red |]
169
     ; expected_bits_gained = 3.5873261452560086
170
     ; expected_bits_remaining = 1.7346019496313541
171
     ; min_bits_gained = 2.7369655941662066
172
     ; max_bits_gained = 5.3219280948873626
173
     ; max_bits_remaining = 2.5849625007211561
174
     ; by_cue =
175
         [ { cue = { white = 2; black = 1 }
176
           ; size_remaining = 4
177
           ; bits_remaining = 2.
178
           ; bits_gained = 3.3219280948873626
179
           ; probability = 0.1
180
           ; next_best_guesses = Not_computed
181
           }
182
         ]
183
     })
184
    (5,
185
     { candidate = [| Green;  Orange;  Yellow;  Yellow;  Yellow |]
186
     ; expected_bits_gained = 2.
187
     ; expected_bits_remaining = 0.
188
     ; min_bits_gained = 2.
189
     ; max_bits_gained = 2.
190
     ; max_bits_remaining = 0.
191
     ; by_cue =
192
         [ { cue = { white = 1; black = 1 }
193
           ; size_remaining = 1
194
           ; bits_remaining = 0.
195
           ; bits_gained = 2.
196
           ; probability = 0.25
197
           ; next_best_guesses = Not_computed
198
           }
199
         ]
200
     })
201
    (6,
202
     { candidate = [| Green;  Blue;  Orange;  White;  Red |]
203
     ; expected_bits_gained = 0.
204
     ; expected_bits_remaining = 0.
205
     ; min_bits_gained = 0.
206
     ; max_bits_gained = 0.
207
     ; max_bits_remaining = 0.
208
     ; by_cue =
209
         [ { cue = { white = 0; black = 5 }
210
           ; size_remaining = 1
211
           ; bits_remaining = 0.
212
           ; bits_gained = 0.
213
           ; probability = 1.
214
           ; next_best_guesses = Not_computed
215
           }
216
         ]
217
     })
218
    |}]
×
219
;;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc