Created
June 19, 2012 21:04
-
-
Save akaptur/2956530 to your computer and use it in GitHub Desktop.
use of else
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def min_val(self, player, depth, max_depth): | |
#print "min_val depth of", depth | |
if self.game_won()[0]: | |
return self.utility() | |
if depth >= max_depth: #do I need =>? | |
return 0 | |
else: | |
depth = depth + 1 | |
min_init = 10 | |
player = self.next_turn(player) | |
availmoves = self.all_legal_moves() | |
options = [] | |
for mymove in availmoves: | |
#print "in min_val" | |
self.make_move(mymove, player) | |
options.append(self.max_val('r', depth, max_depth)) | |
self.unmake_move(mymove, player) | |
minimum = min(min(options), min_init) | |
# print "options in min_val", options | |
return minimum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def max_val(self,player, alpha, beta): | |
if self.game_won()[0]: | |
return self.utility() | |
max_init = -10 | |
player = self.next_turn(player) | |
availmoves = self.all_legal_moves() | |
options = [] | |
for mymove in availmoves: | |
#print "in max_val" | |
self.make_move(mymove, player) | |
options.append(self.min_val('b', alpha, beta)) | |
self.unmake_move(mymove, player) | |
maximum = max(max(options), max_init) | |
print "options in max_val", options | |
return maximum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment