9mm/lib/constants.fnl

92 lines
1.7 KiB
Fennel

(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
])
{: board
: mills
: neighbors
: spaces}