-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtictactoe.template
47 lines (32 loc) · 1.07 KB
/
tictactoe.template
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
import "hashes/sha256/512bitPacked.code" as sha256packed
def main(field gameID, field[2] shaValue, private field[4] pw, private field[4] pl, private field c) -> (field):
field[2] hash1 = sha256packed(pw)
field[2] hash2 = sha256packed(pl)
field[2] hash3 = sha256packed([hash1[0], hash1[1], hash2[0], hash2[1]])
field[2] hash4 = sha256packed([0, gameID, hash3[0], hash3[1]])
hash4[0] == shaValue[0]
hash4[1] == shaValue[1]
field ex = 0
for field i in 0..4 do
field e = if pw[i] == c then 1 else 0 fi
ex = ex + e
endfor
for field i in 0..4 do
field e = if pl[i] == c then 1 else 0 fi
ex = ex + e
endfor
{{content}}
field[5] wcomb = [pw[0], pw[1], pw[2], pw[3], c]
field r = 0
field[3] comb0 = [0, 1, 2]
field[3] comb1 = [3, 4, 5]
field[3] comb2 = [6, 7, 8]
field[3] comb3 = [0, 3, 6]
field[3] comb4 = [1, 4, 7]
field[3] comb5 = [2, 5, 8]
field[3] comb6 = [0, 4, 8]
field[3] comb7 = [2, 4, 6]
{{combs}}
field fr = ex + if r==0 then 1 else 0 fi
fr == 0
return 1