diff options
author | Matt Strapp <strap012@umn.edu> | 2021-04-27 13:59:04 -0500 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2021-04-27 13:59:04 -0500 |
commit | 7380a8eb17f9ddc281d6626036eac985ad091ba7 (patch) | |
tree | 46d1af1566e7fd81635498f5d181ed08da5058b1 | |
parent | Fix bad package import (diff) | |
download | csci4511w-7380a8eb17f9ddc281d6626036eac985ad091ba7.tar csci4511w-7380a8eb17f9ddc281d6626036eac985ad091ba7.tar.gz csci4511w-7380a8eb17f9ddc281d6626036eac985ad091ba7.tar.bz2 csci4511w-7380a8eb17f9ddc281d6626036eac985ad091ba7.tar.lz csci4511w-7380a8eb17f9ddc281d6626036eac985ad091ba7.tar.xz csci4511w-7380a8eb17f9ddc281d6626036eac985ad091ba7.tar.zst csci4511w-7380a8eb17f9ddc281d6626036eac985ad091ba7.zip |
Get it to function
-rw-r--r-- | python/alphaBeta.py | 16 |
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 |