Skip to content

Instantly share code, notes, and snippets.

@akaptur
Created June 19, 2012 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akaptur/2956530 to your computer and use it in GitHub Desktop.
Save akaptur/2956530 to your computer and use it in GitHub Desktop.
use of else
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
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