aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/alphaBeta.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/python/alphaBeta.py b/python/alphaBeta.py
index c15f371..5fe06c8 100644
--- a/python/alphaBeta.py
+++ b/python/alphaBeta.py
@@ -28,7 +28,7 @@ class ABNode(object): # A class for Node related operations
def Make(self, r,c,o): # Function for generating a child node
self.children[(r,c,o)] = ABNode(self.Current)
move=(r,c,o)
- self.children[(r,c,o)].play_move(move)
+ self.children[(r,c,o)].Current.play_move(move)
self.children[(r,c,o)].update_score()
def Populate(self, r,c,o, Child): # Function for adding a node
@@ -40,12 +40,12 @@ class ABNode(object): # A class for Node related operations
# A class for defining algorithms used (minimax and alpha-beta pruning)
class AlphaBeta(object):
- def miniMax(State, Ply_num): # Function for the minimax algorithm
+ def miniMax(self, State, Ply_num): # Function for the minimax algorithm
start=ABNode(State)
possiblemoves=State.get_moves()
for x in possiblemoves:
if (x[0],x[1],x[2]) not in start.children:
- State.Make(x[0],x[1],x[2])
+ start.Make(x[0],x[1],x[2])
if Ply_num < 2:
return (i, j)
@@ -54,7 +54,7 @@ class AlphaBeta(object):
c = 0
o = ""
for k, z in start.children.items():
- Result = Algo.Maximum(z, Ply_num - 1, Minimum_Score)
+ Result = self.Maximum(z, Ply_num - 1, Minimum_Score)
if Minimum_Score > Result:
Minimum_Score = Result
r = k[0]
@@ -64,11 +64,11 @@ class AlphaBeta(object):
return (r,c,o)
# Alpha-beta pruning function for taking care of Alpha values
- def Maximum(State, Ply_num, Alpha):
+ def Maximum(self, State, Ply_num, Alpha):
if Ply_num == 0:
return State.CurrentScore
- possiblemoves=State.get_moves()
+ possiblemoves=State.Current.get_moves()
for x in possiblemoves:
if (x[0],x[1],x[2]) not in State.children:
State.Make(x[0],x[1],x[2])
@@ -78,7 +78,7 @@ class AlphaBeta(object):
c = 0
o=""
for k, z in State.children.items():
- Result = Algo.Minimum(z, Ply_num - 1, Maximum_Score)
+ Result = AlphaBeta.Minimum(z, Ply_num - 1, Maximum_Score)
if Maximum_Score < Result:
Maximum_Score = Result
if Result > Alpha:
@@ -86,7 +86,7 @@ class AlphaBeta(object):
return Maximum_Score
- def Minimum(State, Ply_num, Beta): # Alpha-beta pruning function for taking care of Beta values
+ def Minimum(self, State, Ply_num, Beta): # Alpha-beta pruning function for taking care of Beta values
if Ply_num == 0:
return State.CurrentScore