blob: 996c11c703bb6d9ea8ae1fffc604dee18b2ab7f8 (
plain)
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
|
(local neighbors
[
[1 2 10]
[2 1 3 5]
[3 2 15]
[4 5 11]
[5 2 4 6 8]
[6 5 14]
[7 8 12]
[8 5 7 9]
[9 8 13]
[10 1 11 22]
[11 4 10 12 19]
[12 7 11 16]
[13 9 14 18]
[14 6 13 15 21]
[15 3 14 24]
[16 12 17]
[17 16 18 20]
[18 13 17]
[19 11 20]
[20 17 19 21 23]
[21 14 20]
[22 10 23]
[23 20 22 24]
[24 15 23]
])
(local mills
[
[1 2 3]
[4 5 6]
[7 8 9]
[10 11 12]
[13 14 15]
[16 17 18]
[19 20 21]
[22 23 24]
[1 10 22]
[4 11 19]
[7 12 16]
[2 5 8]
[17 20 23]
[9 13 18]
[6 14 21]
[3 15 24]
])
; these are the only moves that are valid
; i am somewhat bothered by all the wasted space
; by 2-3A and 5-6A e.g.
; Incidentally these are all in order of appearance
; so when you find a match,
; you can also update that index of `moves` to the current player number
(local spaces [
"1A" "4A" "7A"
"2B" "4B" "6B"
"3C" "4C" "5C"
"1D" "2D" "3D"
"5D" "6D" "7D"
"3E" "4E" "5E"
"2F" "4F" "6F"
"1G" "4G" "7G"
])
; This is what the game board looks like
; it's also used to display the state of the game
; the Xs are converted to "%d" later for string templating
; they are Xs here so that it looks pretty =)
(local board [
" 1 2 3 4 5 6 7"
"A x-----x-----x" ;; 1 2 3
" | | |" ;;
"B | x---x---x |" ;; 4 5 6
" | | | | |" ;;
"C | | x-x-x | |" ;; 7 8 9
" | | | | | |" ;;
"D x-x-x x-x-x" ;; 10 11 12 13 14 15
" | | | | | |" ;;
"E | | x-x-x | |" ;; 16 17 18
" | | | | |" ;;
"F | x---x---x |" ;; 19 20 21
" | | |" ;;
"G x-----x-----x" ;; 22 23 24
])
;; there are three phases of play:
;; placing, moving, and flying.
;; (plus one for capturing)
;; (plus one for game-over)
(local stages {
:placing 1 ;; placing the cows
:moving 2 ;; moving the cows
:flying 3 ;; flying the cows
:capture 4 ;; capture a cow (we do not shoot cows)
:complete 5 ;; no more cows! jk the cows are fine. the game's just over okay
})
;; errror codes
(local errors {
:not-a-space "That space does not exist!\nHint: 1a 1A A1 a1 are all the same move."
:occupied "That space is occupied!"
:not-an-opponent "Choose an opponent's piece to remove."
:is-mill "Ma'am, it is ILLEGAL to break up a mill."
:bad-move-format "Try a move like B2B4 or A7 D7"
:not-yours "That's not yours, don't touch it."
:not-neighbor "That ain't your neighbor, Johnny"
})
;; if you like it then you shoulda put a ...
(local rings {
:outer [ 1 2 3 15 24 23 22 10 ]
:middle [ 4 5 6 14 21 20 19 11 ]
:inner [ 7 8 9 13 18 17 16 12 ]
})
{
: board
: errors
: mills
: neighbors
: rings
: spaces
: stages
}
|