-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestsMinimax.idr
114 lines (98 loc) · 2.3 KB
/
TestsMinimax.idr
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
module Main
import Data.Vect
import Specdris.Spec
import Utils
import Minimax
gf1 : GameField
gf1 = [
P X, P X, P O,
P X, P X, P O,
P O, P O, Blank
]
gf2 : GameField
gf2 = [
P X, Blank, P O,
P X, P X, P O,
P O, P O, Blank
]
gf9 : GameField
gf9 = [
Blank, Blank, Blank,
Blank, Blank, Blank,
Blank, Blank, Blank
]
gfDraw : GameField
gfDraw = [
P O, P X, P X,
P X, P X, P O,
P O, P O, P X
]
gf1X : GameField
gf1X = [
P X, P X, P O,
P X, P X, P O,
P O, P O, P X
]
gf1O : GameField
gf1O = [
P X, P X, P O,
P X, P X, P O,
P O, P O, P O
]
gf2BO : GameField
gf2BO = [
P X, Blank, P O,
P X, P X, P O,
P O, P O, P O
]
gf2BX : GameField
gf2BX = [
P X, Blank, P O,
P X, P X, P O,
P O, P O, P X
]
gf2OB : GameField
gf2OB = [
P X, P O, P O,
P X, P X, P O,
P O, P O, Blank
]
gf2XB : GameField
gf2XB = [
P X, P X, P O,
P X, P X, P O,
P O, P O, Blank
]
Show Position where
show p = show $ finToNat p
PMType : Type
PMType = List (Position, GameField)
main : IO ()
main = spec $ do
describe "$ possibleMoves tests" $ do
describe "this is 1 step test" $ do
it "adds one X to the only empty position on field" $ do
possibleMoves X gf1 `shouldBe` [(8, gf1X)]
it "adds one O to the only empty position on field" $ do
possibleMoves O gf1 `shouldBe` [(8, gf1O)]
it "adds one X to each of 2 empty spaces, one by one" $ do
possibleMoves X gf2 `shouldBe` [(8, gf2BX), (1, gf2XB)]
it "adds one O to each of 2 empty spaces, one by one" $ do
possibleMoves O gf2 `shouldBe` [(8, gf2BO), (1, gf2OB)]
describe "amount of cases" $ do
it "adds X to the only empty space" $ do
(length $ possibleMoves X gf1) `shouldBe` 1
it "adds X to each of two empty spaces" $ do
(length $ possibleMoves X gf2) `shouldBe` 2
it "adds X to each of nine empty spaces" $ do
(length $ possibleMoves X gf9) `shouldBe` 9
it "adds O to each of nine empty spaces" $ do
(length $ possibleMoves O gf9) `shouldBe` 9
it "tryes to add moves to full field" $ do
(length $ possibleMoves X gfDraw) `shouldBe` 0
describe "$ last index" $ do
it "takes last index of GameField" $ do
finToNat (lastIndex gf1) `shouldBe` (FieldSize - 1)
-- Local Variables:
-- idris-load-packages: ("specdris")
-- End: