-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStateEvaluator.py
More file actions
34 lines (27 loc) · 849 Bytes
/
StateEvaluator.py
File metadata and controls
34 lines (27 loc) · 849 Bytes
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
from config import EMPTYCELL
from config import BLACKCELL
from config import WHITECELL
from state import State
from MovesGenerator import MovesGenerator
def is_gameover(state):
obj = MovesGenerator()
is_over = True
is_over = is_over and not obj.getNextStates(state)
state.reverse_State()
is_over = is_over and not obj.getNextStates(state)
state.reverse_State()
return is_over
def evaluate(state, oppColor=WHITECELL):
white_Counter = 0
black_Counter = 0
for row in state.board:
for col in row:
if (col == BLACKCELL):
black_Counter += 1
if (col == WHITECELL):
white_Counter += 1
# wa always play as black
if(oppColor == WHITECELL):
return black_Counter - white_Counter
else:
return white_Counter - black_Counter