-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_board.ml
1034 lines (850 loc) · 34.5 KB
/
test_board.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* Tests for CS 4 final exam, Winter 2019, part B. *)
open Storage
open Board
open OUnit2
open Printf
(*** Utility functions. ***)
(* Expect an Invalid_argument exception. *)
let expect_invalid_arg msg thunk =
assert_bool msg
(try (thunk (); false)
with Invalid_argument _ -> true)
(* Expect a Failure exception. *)
let expect_failure msg thunk =
assert_bool msg
(try (thunk (); false)
with Failure _ -> true)
(* Take the first n elements from a list. *)
let rec take n lst =
match (n, lst) with
| (0, _) -> []
| (_, []) -> failwith "take: invalid input"
| (_, h :: t) -> h :: take (n - 1) t
(* Convert a list of lists of integers to a string. *)
let string_of_list_of_lists lol =
let string_of_list lst =
"[" ^ String.concat "; " (List.map string_of_int lst) ^ "]"
in
"[" ^ String.concat ";\n " (List.map string_of_list lol) ^ "]\n"
let print_list_of_lists lol =
print_string (string_of_list_of_lists lol)
(* Compare two lists of (loc, int) pairs for equality.
* Report an error if there is a discrepancy. *)
let compare_loc_int_lists label lil1 lil2 =
let compare_loc_int i li1 li2 =
if li1 <> li2 then
let ((r1, c1), i1) = li1 in
let ((r2, c2), i2) = li2 in
begin
printf "%s: index %d: different values: ((%d, %d), %d) vs ((%d, %d), %d)\n%!"
label i r1 c1 i1 r2 c2 i2;
false
end
else true
in
let len1 = List.length lil1 in
let len2 = List.length lil2 in
if len1 <> len2 then
begin
printf "%s: different numbers of items: %d vs %d\n%!"
label len1 len2;
false
end
else
(* Sort lists so order doesn't matter. *)
let slil1 = List.sort compare lil1 in
let slil2 = List.sort compare lil2 in
let rec iter i lil1 lil2 =
match (lil1, lil2) with
| ([], []) -> true (* equal! *)
| (h1 :: t1, h2 :: t2) ->
if compare_loc_int i h1 h2 then
iter (i + 1) t1 t2
else
false
| _ -> failwith "this should never happen"
in
iter 0 slil1 slil2
(* Compare two lists of lists of integers for equality.
* Report an error if there is a discrepancy. *)
let compare_list_of_lists label lol1 lol2 =
let compare_items r c i1 i2 =
if i1 <> i2 then
begin
printf "%s: row %d: column %d: different values: %d vs %d\n%!"
label r c i1 i2;
false
end
else true
in
let compare_lists r lst1 lst2 =
let len1 = List.length lst1 in
let len2 = List.length lst2 in
if len1 <> len2 then
begin
printf "%s: row %d: different numbers of columns: %d vs %d\n%!"
label r len1 len2;
false
end
else
let rec iter_c c l1 l2 =
match (l1, l2) with
| ([], []) -> true (* equal! *)
| (h1 :: t1, h2 :: t2) ->
if compare_items r c h1 h2 then
iter_c (c + 1) t1 t2
else
false
| _ -> failwith "this should never happen"
in
iter_c 0 lst1 lst2
in
let len1 = List.length lol1 in
let len2 = List.length lol2 in
if len1 <> len2 then
begin
printf "%s: different numbers of rows: %d vs %d\n%!"
label len1 len2;
false
end
else
let rec iter_r r l1 l2 =
match (l1, l2) with
| ([], []) -> true (* equal! *)
| (h1 :: t1, h2 :: t2) ->
if compare_lists r h1 h2 then
iter_r (r + 1) t1 t2
else
false
| _ -> failwith "this should never happen"
in
iter_r 0 lol1 lol2
module BoardTests (B: Board) =
struct
let get_all f board noneval =
let (nrows, ncols) = B.get_dimensions board in
let rec iter r c current_row prev_rows =
match () with
| _ when r = nrows ->
List.rev prev_rows
| _ when c = ncols ->
iter (r + 1) 0 [] ((List.rev current_row) :: prev_rows)
| _ ->
let curr =
match f board (r, c) with
| None -> noneval
| Some i -> i
in
iter r (c + 1) (curr :: current_row) prev_rows
in
iter 0 0 [] []
(* Get all board indices as a list of lists. *)
let get_all_index board = get_all B.get_index board 0
(* Get all board reachables as a list of lists. *)
let get_all_reachable board = get_all B.get_reachable board (-1)
(* Get the initial reachables of an empty board with `nrows` rows
* and `ncols` columns, as a list of lists. *)
let get_init_reach nrows ncols =
let board = B.make nrows ncols in
get_all_reachable board
(* Get loc counts from a loc as a list after n moves from a list
* of placements. *)
let get_loc_counts_from_loc_after_n board loc placements n =
let b =
List.fold_left (fun b p -> B.place b p) board (take n placements)
in
B.get_loc_counts_from_loc b loc
(* Get all board indices as a list of lists after n moves from a list
* of placements. *)
let place_all_get_indices board placements n =
let b =
List.fold_left (fun b p -> B.place b p) board (take n placements)
in
get_all_index b
(* Get all board reachables as a list of lists after n moves from a list
* of placements. *)
let place_all_get_reachable board placements n =
let b =
List.fold_left (fun b p -> B.place b p) board (take n placements)
in
get_all_reachable b
(* Like `place_all_get_indices`, but with the last move undone. *)
let place_all_get_indices_undo board placements n =
let b =
List.fold_left (fun b p -> B.place b p) board (take n placements)
in
let b' = B.undo b in
get_all_index b'
(* Like `place_all_get_reachables`, but with the last move undone. *)
let place_all_get_reachable_undo board placements n =
let b =
List.fold_left (fun b p -> B.place b p) board (take n placements)
in
let b' = B.undo b in
get_all_reachable b'
end
module BI = Board.Make(ImpStorage)
module BF = Board.Make(FunStorage)
module TI = BoardTests(BI)
module TF = BoardTests(BF)
(*** Useful testing data. ***)
(* Initial reachables of MxN boards, as lists of lists with one sublist
* = one row. *)
let init_reach_1_1 = [[0]]
let init_reach_1_5 = [[0;0;0;0;0]]
let init_reach_3_4 = [[2;3;3;2];[2;2;2;2];[2;3;3;2]]
let init_reach_4_3 = [[2;2;2];[3;2;3];[3;2;3];[2;2;2]]
let init_reach_4_4 = [[2;3;3;2];[3;4;4;3];[3;4;4;3];[2;3;3;2]]
let init_reach_4_5 = [[2;3;4;3;2];[3;4;6;4;3];[3;4;6;4;3];[2;3;4;3;2]]
let init_reach_8_8 =
[
[2;3;4;4;4;4;3;2];
[3;4;6;6;6;6;4;3];
[4;6;8;8;8;8;6;4];
[4;6;8;8;8;8;6;4];
[4;6;8;8;8;8;6;4];
[4;6;8;8;8;8;6;4];
[3;4;6;6;6;6;4;3];
[2;3;4;4;4;4;3;2]
]
(* Moves (placements) required to make a knight's tour on a 3x4 board. *)
let moves_3_4 =
[(0,0);(1,2);(2,0);(0,1);(1,3);(2,1);(0,2);(2,3);(1,1);(0,3);(2,2);(1,0)]
(* Indices on a 3x4 board after N moves. *)
let index_3_4_0 = [[0;0;0;0]; [0;0;0;0]; [0;0;0;0]]
let index_3_4_1 = [[1;0;0;0]; [0;0;0;0]; [0;0;0;0]]
let index_3_4_2 = [[1;0;0;0]; [0;0;2;0]; [0;0;0;0]]
let index_3_4_3 = [[1;0;0;0]; [0;0;2;0]; [3;0;0;0]]
let index_3_4_4 = [[1;4;0;0]; [0;0;2;0]; [3;0;0;0]]
let index_3_4_5 = [[1;4;0;0]; [0;0;2;5]; [3;0;0;0]]
let index_3_4_6 = [[1;4;0;0]; [0;0;2;5]; [3;6;0;0]]
let index_3_4_7 = [[1;4;7;0]; [0;0;2;5]; [3;6;0;0]]
let index_3_4_8 = [[1;4;7;0]; [0;0;2;5]; [3;6;0;8]]
let index_3_4_9 = [[1;4;7;0]; [0;9;2;5]; [3;6;0;8]]
let index_3_4_10 = [[1;4;7;10];[0;9;2;5]; [3;6;0;8]]
let index_3_4_11 = [[1;4;7;10];[0;9;2;5]; [3;6;11;8]]
let index_3_4_12 = [[1;4;7;10];[12;9;2;5];[3;6;11;8]]
(* Reachables on a 3x4 board after N moves. *)
let reachable_3_4_0 = [[2;3;3;2]; [2;2;2;2]; [2;3;3;2]]
let reachable_3_4_1 = [[-1;3;3;2]; [2;2;1;2]; [2;2;3;2]]
let reachable_3_4_2 = [[-1;3;3;2]; [2;2;-1;2]; [1;2;3;2]]
let reachable_3_4_3 = [[-1;2;3;2]; [2;2;-1;2]; [-1;2;3;2]]
let reachable_3_4_4 = [[-1;-1;3;2]; [2;2;-1;1]; [-1;2;2;2]]
let reachable_3_4_5 = [[-1;-1;3;2]; [2;2;-1;-1]; [-1;1;2;2]]
let reachable_3_4_6 = [[-1;-1;2;2]; [2;2;-1;-1]; [-1;-1;2;2]]
let reachable_3_4_7 = [[-1;-1;-1;2]; [1;2;-1;-1]; [-1;-1;2;1]]
let reachable_3_4_8 = [[-1;-1;-1;2]; [1;1;-1;-1]; [-1;-1;2;-1]]
let reachable_3_4_9 = [[-1;-1;-1;1]; [1;-1;-1;-1]; [-1;-1;2;-1]]
let reachable_3_4_10 = [[-1;-1;-1;-1];[1;-1;-1;-1]; [-1;-1;1;-1]]
let reachable_3_4_11 = [[-1;-1;-1;-1];[0;-1;-1;-1]; [-1;-1;-1;-1]]
let reachable_3_4_12 = [[-1;-1;-1;-1];[-1;-1;-1;-1];[-1;-1;-1;-1]]
let loc_int_list_3_4_0_0_0 = [((1,2),2); ((2,1),3)]
let loc_int_list_3_4_0_0_1 = [((2,0),2); ((2,2),3); ((1,3),2)]
let loc_int_list_3_4_3_0_0 = [((2,1),2)]
let loc_int_list_3_4_3_1_2 = []
let loc_int_list_3_4_3_1_3 = [((0,1),2); ((2,1),2)]
let loc_int_list_3_4_3_2_0 = [((0,1),2)]
(*** The tests. ***)
let all_tests = "all_tests" >:::
[
"make: invalid args" >:: (fun _ ->
begin
expect_invalid_arg "bad make 1" (fun _ -> BI.make (-1) (-1));
expect_invalid_arg "bad make 2" (fun _ -> BF.make (-1) (-1));
expect_invalid_arg "bad make 3" (fun _ -> BI.make (-1) 0);
expect_invalid_arg "bad make 4" (fun _ -> BF.make (-1) 0);
expect_invalid_arg "bad make 5" (fun _ -> BI.make 0 (-1));
expect_invalid_arg "bad make 6" (fun _ -> BF.make 0 (-1));
expect_invalid_arg "bad make 7" (fun _ -> BI.make 0 0);
expect_invalid_arg "bad make 8" (fun _ -> BF.make 0 0);
end
);
"make: init_reachable" >:: (fun _ ->
begin
assert_bool "init reach 1i"
(compare_list_of_lists "init reach 1i"
(TI.get_init_reach 1 1) init_reach_1_1);
assert_bool "init reach 2i"
(compare_list_of_lists "init reach 2i"
(TI.get_init_reach 1 5) init_reach_1_5);
assert_bool "init reach 3i"
(compare_list_of_lists "init reach 3i"
(TI.get_init_reach 3 4) init_reach_3_4);
assert_bool "init reach 4i"
(compare_list_of_lists "init reach 4i"
(TI.get_init_reach 4 3) init_reach_4_3);
assert_bool "init reach 5i"
(compare_list_of_lists "init reach 5i"
(TI.get_init_reach 4 4) init_reach_4_4);
assert_bool "init reach 6i"
(compare_list_of_lists "init reach 6i"
(TI.get_init_reach 4 5) init_reach_4_5);
assert_bool "init reach 7i"
(compare_list_of_lists "init reach 7i"
(TI.get_init_reach 8 8) init_reach_8_8);
assert_bool "init reach 1f"
(compare_list_of_lists "init reach 1f"
(TF.get_init_reach 1 1) init_reach_1_1);
assert_bool "init reach 2f"
(compare_list_of_lists "init reach 2f"
(TF.get_init_reach 1 5) init_reach_1_5);
assert_bool "init reach 3f"
(compare_list_of_lists "init reach 3f"
(TF.get_init_reach 3 4) init_reach_3_4);
assert_bool "init reach 4f"
(compare_list_of_lists "init reach 4f"
(TF.get_init_reach 4 3) init_reach_4_3);
assert_bool "init reach 5f"
(compare_list_of_lists "init reach 5f"
(TF.get_init_reach 4 4) init_reach_4_4);
assert_bool "init reach 6f"
(compare_list_of_lists "init reach 6f"
(TF.get_init_reach 4 5) init_reach_4_5);
assert_bool "init reach 7f"
(compare_list_of_lists "init reach 7f"
(TF.get_init_reach 8 8) init_reach_8_8);
end
);
"get_loc_counts_from_loc: bad input" >:: (fun _ ->
begin
expect_invalid_arg "bad get_loc_counts 1i"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.get_loc_counts_from_loc b ((-1), (-1)))
);
expect_invalid_arg "bad get_loc_counts 2i"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.get_loc_counts_from_loc b ((-1), 0))
);
expect_invalid_arg "bad get_loc_counts 3i"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.get_loc_counts_from_loc b (0, (-1)))
);
expect_invalid_arg "bad get_loc_counts 1f"
(fun _ ->
let b = BF.make 3 4 in
ignore (BF.get_loc_counts_from_loc b ((-1), (-1)))
);
expect_invalid_arg "bad get_loc_counts 2f"
(fun _ ->
let b = BF.make 3 4 in
ignore (BF.get_loc_counts_from_loc b ((-1), 0))
);
expect_invalid_arg "bad get_loc_counts 3f"
(fun _ ->
let b = BF.make 3 4 in
ignore (BF.get_loc_counts_from_loc b (0, (-1)))
);
end
);
"get_loc_counts_from_loc" >:: (fun _ ->
begin
assert_bool "get_loc_counts_from_loc 0i"
(compare_loc_int_lists "get_loc_counts_from_loc 0i"
(BI.get_loc_counts_from_loc (BI.make 3 4) (0, 0))
loc_int_list_3_4_0_0_0);
assert_bool "get_loc_counts_from_loc 1i"
(compare_loc_int_lists "get_loc_counts_from_loc 1i"
(BI.get_loc_counts_from_loc (BI.make 3 4) (0, 1))
loc_int_list_3_4_0_0_1);
assert_bool "get_loc_counts_from_loc 2i"
(compare_loc_int_lists "get_loc_counts_from_loc 2i"
(TI.get_loc_counts_from_loc_after_n (BI.make 3 4) (0, 0) moves_3_4 3)
loc_int_list_3_4_3_0_0);
assert_bool "get_loc_counts_from_loc 3i"
(compare_loc_int_lists "get_loc_counts_from_loc 3i"
(TI.get_loc_counts_from_loc_after_n (BI.make 3 4) (1, 2) moves_3_4 3)
loc_int_list_3_4_3_1_2);
assert_bool "get_loc_counts_from_loc 4i"
(compare_loc_int_lists "get_loc_counts_from_loc 4i"
(TI.get_loc_counts_from_loc_after_n (BI.make 3 4) (1, 3) moves_3_4 3)
loc_int_list_3_4_3_1_3);
assert_bool "get_loc_counts_from_loc 5i"
(compare_loc_int_lists "get_loc_counts_from_loc 5i"
(TI.get_loc_counts_from_loc_after_n (BI.make 3 4) (2, 0) moves_3_4 3)
loc_int_list_3_4_3_2_0);
end
);
"place: bad input" >:: (fun _ ->
begin
expect_invalid_arg "bad place 1i"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.place b ((-1), (-1)))
);
expect_invalid_arg "bad place 2i"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.place b ((-1), 0))
);
expect_invalid_arg "bad place 3i"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.place b (0, (-1)))
);
expect_invalid_arg "bad place 4i"
(fun _ ->
let b = BI.make 3 4 in
let b2 = BI.place b (0, 0) in
ignore (BI.place b2 (0, 0))
);
expect_invalid_arg "bad place 5i"
(fun _ ->
let b = BI.make 3 4 in
let b2 = BI.place b (0, 0) in
ignore (BI.place b2 (0, 1))
);
expect_invalid_arg "bad place 1f"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.place b ((-1), (-1)))
);
expect_invalid_arg "bad place 2f"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.place b ((-1), 0))
);
expect_invalid_arg "bad place 3f"
(fun _ ->
let b = BI.make 3 4 in
ignore (BI.place b (0, (-1)))
);
expect_invalid_arg "bad place 4f"
(fun _ ->
let b = BI.make 3 4 in
let b2 = BI.place b (0, 0) in
ignore (BI.place b2 (0, 0))
);
expect_invalid_arg "bad place 5f"
(fun _ ->
let b = BI.make 3 4 in
let b2 = BI.place b (0, 0) in
ignore (BI.place b2 (0, 1))
);
end
);
"place: indices" >:: (fun _ ->
begin
assert_bool "place indices 0i"
(compare_list_of_lists "place indices 0i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 0)
index_3_4_0);
assert_bool "place indices 1i"
(compare_list_of_lists "place indices 1i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 1)
index_3_4_1);
assert_bool "place indices 2i"
(compare_list_of_lists "place indices 2i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 2)
index_3_4_2);
assert_bool "place indices 3i"
(compare_list_of_lists "place indices 3i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 3)
index_3_4_3);
assert_bool "place indices 4i"
(compare_list_of_lists "place indices 4i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 4)
index_3_4_4);
assert_bool "place indices 5i"
(compare_list_of_lists "place indices 5i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 5)
index_3_4_5);
assert_bool "place indices 6i"
(compare_list_of_lists "place indices 6i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 6)
index_3_4_6);
assert_bool "place indices 7i"
(compare_list_of_lists "place indices 7i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 7)
index_3_4_7);
assert_bool "place indices 8i"
(compare_list_of_lists "place indices 8i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 8)
index_3_4_8);
assert_bool "place indices 9i"
(compare_list_of_lists "place indices 9i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 9)
index_3_4_9);
assert_bool "place indices 10i"
(compare_list_of_lists "place indices 10i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 10)
index_3_4_10);
assert_bool "place indices 11i"
(compare_list_of_lists "place indices 11i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 11)
index_3_4_11);
assert_bool "place indices 12i"
(compare_list_of_lists "place indices 12i"
(TI.place_all_get_indices (BI.make 3 4) moves_3_4 12)
index_3_4_12);
assert_bool "place indices 0f"
(compare_list_of_lists "place indices 0f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 0)
index_3_4_0);
assert_bool "place indices 1f"
(compare_list_of_lists "place indices 1f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 1)
index_3_4_1);
assert_bool "place indices 2f"
(compare_list_of_lists "place indices 2f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 2)
index_3_4_2);
assert_bool "place indices 3f"
(compare_list_of_lists "place indices 3f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 3)
index_3_4_3);
assert_bool "place indices 4f"
(compare_list_of_lists "place indices 4f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 4)
index_3_4_4);
assert_bool "place indices 5f"
(compare_list_of_lists "place indices 5f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 5)
index_3_4_5);
assert_bool "place indices 6f"
(compare_list_of_lists "place indices 6f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 6)
index_3_4_6);
assert_bool "place indices 7f"
(compare_list_of_lists "place indices 7f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 7)
index_3_4_7);
assert_bool "place indices 8f"
(compare_list_of_lists "place indices 8f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 8)
index_3_4_8);
assert_bool "place indices 9f"
(compare_list_of_lists "place indices 9f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 9)
index_3_4_9);
assert_bool "place indices 10f"
(compare_list_of_lists "place indices 10f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 10)
index_3_4_10);
assert_bool "place indices 11f"
(compare_list_of_lists "place indices 11f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 11)
index_3_4_11);
assert_bool "place indices 12f"
(compare_list_of_lists "place indices 12f"
(TF.place_all_get_indices (BF.make 3 4) moves_3_4 12)
index_3_4_12);
end
);
"place: reachable" >:: (fun _ ->
begin
assert_bool "place reachable 0i"
(compare_list_of_lists "place reachable 0i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 0)
reachable_3_4_0);
assert_bool "place reachable 1i"
(compare_list_of_lists "place reachable 1i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 1)
reachable_3_4_1);
assert_bool "place reachable 2i"
(compare_list_of_lists "place reachable 2i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 2)
reachable_3_4_2);
assert_bool "place reachable 3i"
(compare_list_of_lists "place reachable 3i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 3)
reachable_3_4_3);
assert_bool "place reachable 4i"
(compare_list_of_lists "place reachable 4i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 4)
reachable_3_4_4);
assert_bool "place reachable 5i"
(compare_list_of_lists "place reachable 5i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 5)
reachable_3_4_5);
assert_bool "place reachable 6i"
(compare_list_of_lists "place reachable 6i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 6)
reachable_3_4_6);
assert_bool "place reachable 7i"
(compare_list_of_lists "place reachable 7i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 7)
reachable_3_4_7);
assert_bool "place reachable 8i"
(compare_list_of_lists "place reachable 8i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 8)
reachable_3_4_8);
assert_bool "place reachable 9i"
(compare_list_of_lists "place reachable 9i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 9)
reachable_3_4_9);
assert_bool "place reachable 10i"
(compare_list_of_lists "place reachable 10i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 10)
reachable_3_4_10);
assert_bool "place reachable 11i"
(compare_list_of_lists "place reachable 11i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 11)
reachable_3_4_11);
assert_bool "place reachable 12i"
(compare_list_of_lists "place reachable 12i"
(TI.place_all_get_reachable (BI.make 3 4) moves_3_4 12)
reachable_3_4_12);
assert_bool "place reachable 0f"
(compare_list_of_lists "place reachable 0f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 0)
reachable_3_4_0);
assert_bool "place reachable 1f"
(compare_list_of_lists "place reachable 1f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 1)
reachable_3_4_1);
assert_bool "place reachable 2f"
(compare_list_of_lists "place reachable 2f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 2)
reachable_3_4_2);
assert_bool "place reachable 3f"
(compare_list_of_lists "place reachable 3f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 3)
reachable_3_4_3);
assert_bool "place reachable 4f"
(compare_list_of_lists "place reachable 4f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 4)
reachable_3_4_4);
assert_bool "place reachable 5f"
(compare_list_of_lists "place reachable 5f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 5)
reachable_3_4_5);
assert_bool "place reachable 6f"
(compare_list_of_lists "place reachable 6f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 6)
reachable_3_4_6);
assert_bool "place reachable 7f"
(compare_list_of_lists "place reachable 7f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 7)
reachable_3_4_7);
assert_bool "place reachable 8f"
(compare_list_of_lists "place reachable 8f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 8)
reachable_3_4_8);
assert_bool "place reachable 9f"
(compare_list_of_lists "place reachable 9f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 9)
reachable_3_4_9);
assert_bool "place reachable 10f"
(compare_list_of_lists "place reachable 10f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 10)
reachable_3_4_10);
assert_bool "place reachable 11f"
(compare_list_of_lists "place reachable 11f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 11)
reachable_3_4_11);
assert_bool "place reachable 12f"
(compare_list_of_lists "place reachable 12f"
(TF.place_all_get_reachable (BF.make 3 4) moves_3_4 12)
reachable_3_4_12);
end
);
"undo: indices" >:: (fun _ ->
begin
assert_bool "undo indices 1i"
(compare_list_of_lists "undo indices 1i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 1)
index_3_4_0);
assert_bool "undo indices 2i"
(compare_list_of_lists "undo indices 2i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 2)
index_3_4_1);
assert_bool "undo indices 3i"
(compare_list_of_lists "undo indices 3i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 3)
index_3_4_2);
assert_bool "undo indices 4i"
(compare_list_of_lists "undo indices 4i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 4)
index_3_4_3);
assert_bool "undo indices 5i"
(compare_list_of_lists "undo indices 5i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 5)
index_3_4_4);
assert_bool "undo indices 6i"
(compare_list_of_lists "undo indices 6i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 6)
index_3_4_5);
assert_bool "undo indices 7i"
(compare_list_of_lists "undo indices 7i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 7)
index_3_4_6);
assert_bool "undo indices 8i"
(compare_list_of_lists "undo indices 8i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 8)
index_3_4_7);
assert_bool "undo indices 9i"
(compare_list_of_lists "undo indices 9i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 9)
index_3_4_8);
assert_bool "undo indices 10i"
(compare_list_of_lists "undo indices 10i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 10)
index_3_4_9);
assert_bool "undo indices 11i"
(compare_list_of_lists "undo indices 11i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 11)
index_3_4_10);
assert_bool "undo indices 12i"
(compare_list_of_lists "undo indices 12i"
(TI.place_all_get_indices_undo (BI.make 3 4) moves_3_4 12)
index_3_4_11);
assert_bool "undo indices 1f"
(compare_list_of_lists "undo indices 1f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 1)
index_3_4_0);
assert_bool "undo indices 2f"
(compare_list_of_lists "undo indices 2f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 2)
index_3_4_1);
assert_bool "undo indices 3f"
(compare_list_of_lists "undo indices 3f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 3)
index_3_4_2);
assert_bool "undo indices 4f"
(compare_list_of_lists "undo indices 4f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 4)
index_3_4_3);
assert_bool "undo indices 5f"
(compare_list_of_lists "undo indices 5f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 5)
index_3_4_4);
assert_bool "undo indices 6f"
(compare_list_of_lists "undo indices 6f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 6)
index_3_4_5);
assert_bool "undo indices 7f"
(compare_list_of_lists "undo indices 7f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 7)
index_3_4_6);
assert_bool "undo indices 8f"
(compare_list_of_lists "undo indices 8f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 8)
index_3_4_7);
assert_bool "undo indices 9f"
(compare_list_of_lists "undo indices 9f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 9)
index_3_4_8);
assert_bool "undo indices 10f"
(compare_list_of_lists "undo indices 10f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 10)
index_3_4_9);
assert_bool "undo indices 11f"
(compare_list_of_lists "undo indices 11f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 11)
index_3_4_10);
assert_bool "undo indices 12f"
(compare_list_of_lists "undo indices 12f"
(TF.place_all_get_indices_undo (BF.make 3 4) moves_3_4 12)
index_3_4_11);
end
);
"undo: reachable" >:: (fun _ ->
begin
assert_bool "undo reachable 1i"
(compare_list_of_lists "undo reachable 1i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 1)
reachable_3_4_0);
assert_bool "undo reachable 2i"
(compare_list_of_lists "undo reachable 2i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 2)
reachable_3_4_1);
assert_bool "undo reachable 3i"
(compare_list_of_lists "undo reachable 3i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 3)
reachable_3_4_2);
assert_bool "undo reachable 4i"
(compare_list_of_lists "undo reachable 4i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 4)
reachable_3_4_3);
assert_bool "undo reachable 5i"
(compare_list_of_lists "undo reachable 5i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 5)
reachable_3_4_4);
assert_bool "undo reachable 6i"
(compare_list_of_lists "undo reachable 6i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 6)
reachable_3_4_5);
assert_bool "undo reachable 7i"
(compare_list_of_lists "undo reachable 7i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 7)
reachable_3_4_6);
assert_bool "undo reachable 8i"
(compare_list_of_lists "undo reachable 8i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 8)
reachable_3_4_7);
assert_bool "undo reachable 9i"
(compare_list_of_lists "undo reachable 9i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 9)
reachable_3_4_8);
assert_bool "undo reachable 10i"
(compare_list_of_lists "undo reachable 10i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 10)
reachable_3_4_9);
assert_bool "undo reachable 11i"
(compare_list_of_lists "undo reachable 11i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 11)
reachable_3_4_10);
assert_bool "undo reachable 12i"
(compare_list_of_lists "undo reachable 12i"
(TI.place_all_get_reachable_undo (BI.make 3 4) moves_3_4 12)
reachable_3_4_11);
assert_bool "undo reachable 1f"
(compare_list_of_lists "undo reachable 1f"
(TF.place_all_get_reachable_undo (BF.make 3 4) moves_3_4 1)
reachable_3_4_0);
assert_bool "undo reachable 2f"
(compare_list_of_lists "undo reachable 2f"
(TF.place_all_get_reachable_undo (BF.make 3 4) moves_3_4 2)
reachable_3_4_1);
assert_bool "undo reachable 3f"
(compare_list_of_lists "undo reachable 3f"
(TF.place_all_get_reachable_undo (BF.make 3 4) moves_3_4 3)
reachable_3_4_2);
assert_bool "undo reachable 4f"
(compare_list_of_lists "undo reachable 4f"
(TF.place_all_get_reachable_undo (BF.make 3 4) moves_3_4 4)
reachable_3_4_3);
assert_bool "undo reachable 5f"
(compare_list_of_lists "undo reachable 5f"
(TF.place_all_get_reachable_undo (BF.make 3 4) moves_3_4 5)
reachable_3_4_4);
assert_bool "undo reachable 6f"
(compare_list_of_lists "undo reachable 6f"
(TF.place_all_get_reachable_undo (BF.make 3 4) moves_3_4 6)
reachable_3_4_5);
assert_bool "undo reachable 7f"
(compare_list_of_lists "undo reachable 7f"
(TF.place_all_get_reachable_undo (BF.make 3 4) moves_3_4 7)
reachable_3_4_6);
assert_bool "undo reachable 8f"
(compare_list_of_lists "undo reachable 8f"
(TF.place_all_get_reachable_undo (BF.make 3 4) moves_3_4 8)
reachable_3_4_7);