-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathheuristics.py
76 lines (66 loc) · 2.9 KB
/
heuristics.py
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
from util import *
def baby(board, turn):
return 0
def weak(board, turn):
if turn == "W":
return count_pieces(board, "W") - count_pieces(board, "B")
else:
return count_pieces(board, "B") - count_pieces(board, "W")
def greedy(board, turn):
if turn == "W":
return count_pieces(board, "W")
else:
return count_pieces(board, "B")
def posicional(board, turn):
value = 0
for i in range(8):
for j in range(8):
if board[(i, j)] == turn:
if (i == 0 and j == 0) or (i == 7 and j == 7) or \
(i == 0 and j == 7) or (i == 7 and j == 0):
value += 20
elif (i == 3 and j == 3) or (i == 3 and j == 4) or \
(i == 4 and j == 3) or (i == 4 and j == 4):
value += 5
elif (i == 0 and j == 1) or (i == 1 and j == 0) or \
(i == 7 and j == 1) or (i == 6 and j == 0) or \
(i == 0 and j == 6) or (i == 1 and j == 7) or \
(i == 7 and j == 6) or (i == 6 and j == 7) or \
(i == 1 and j == 1) or (i == 6 and j == 6) or \
(i == 6 and j == 1) or (i == 1 and j == 6):
value += 0
else:
value += 10
return value
def marc_mandt_posicional(board, turn):
value = 0
for i in range(8):
for j in range(8):
if board[(i, j)] == turn:
if (i == 0 and j == 0) or (i == 7 and j == 7) or \
(i == 0 and j == 7) or (i == 7 and j == 0):
value += 50
elif (i == 3 and j == 3) or (i == 3 and j == 4) or \
(i == 4 and j == 3) or (i == 4 and j == 4):
pass
elif (i == 0 and j == 1) or (i == 1 and j == 0) or \
(i == 7 and j == 1) or (i == 6 and j == 0) or \
(i == 0 and j == 6) or (i == 1 and j == 7) or \
(i == 7 and j == 6) or (i == 6 and j == 7):
value -= 1
elif (i == 1 and j == 1) or (i == 6 and j == 6) or \
(i == 6 and j == 1) or (i == 1 and j == 6):
value -= 10
elif (i == 0 and j == 2) or (i == 0 and j == 5) or \
(i == 7 and j == 2) or (i == 7 and j == 5) or \
(i == 2 and j == 0) or (i == 5 and j == 0) or \
(i == 2 and j == 7) or (i == 5 and j == 7):
value += 5
elif (i == 0 and j == 3) or (i == 0 and j == 4) or \
(i == 7 and j == 3) or (i == 7 and j == 4) or \
(i == 3 and j == 0) or (i == 4 and j == 0) or \
(i == 3 and j == 7) or (i == 4 and j == 7):
value += 2
else:
value += 1
return value