aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/alphaBeta.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/python/alphaBeta.py b/python/alphaBeta.py
index 6ac0400..52ede74 100644
--- a/python/alphaBeta.py
+++ b/python/alphaBeta.py
@@ -26,7 +26,7 @@ class ABNode(object): # A class for Node related operations
self.CurrentScore = self.Current.score[2]-self.Current.score[1]
def Make(self, r,c,o): # Function for generating a child node
- self.children[(r,c,o)] = ABNode(self.Current)
+ self.children[(r,c,o)] = ABNode(deepcopy(self.Current))
move=(r,c,o)
self.children[(r,c,o)].Current.play_move(move)
self.children[(r,c,o)].update_score()
@@ -41,7 +41,8 @@ class ABNode(object): # A class for Node related operations
class AlphaBeta(object):
def miniMax(self, State, Ply_num): # Function for the minimax algorithm
- start=ABNode(State)
+ State = deepcopy(State)
+ start = ABNode(State)
possiblemoves=State.get_moves()
for x in possiblemoves:
if (x[0],x[1],x[2]) not in start.children:
@@ -78,7 +79,7 @@ class AlphaBeta(object):
c = 0
o=""
for k, z in State.children.items():
- Result = AlphaBeta.Minimum(z, Ply_num - 1, Maximum_Score)
+ Result = self.Minimum(z, Ply_num - 1, Maximum_Score)
if Maximum_Score < Result:
Maximum_Score = Result
if Result > Alpha:
@@ -99,7 +100,7 @@ class AlphaBeta(object):
i = 0
j = 0
for k, z in State.children.items():
- Result = AlphaBeta.Maximum(z, Ply_num - 1, Minimum_Score)
+ Result = self.Maximum(z, Ply_num - 1, Minimum_Score)
if Minimum_Score > Result:
Minimum_Score = Result
if Result < Beta: