Created
January 30, 2014 16:14
-
-
Save jsam/8712190 to your computer and use it in GitHub Desktop.
[DSTG] Zadatak 4.
This file contains hidden or 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 minimax(igrajer, ploca, depth, evaluate): | |
def value(ploca): | |
return -minimax(protivnik(igrajer), ploca, depth-1, evaluate)[0] | |
if depth == 0: | |
return evaluate(igrajer, ploca), None | |
moves = legalan_potez(igrajer, ploca) | |
if not moves: | |
if not bilokoji_lPotez(protivnik(igrajer), ploca): | |
return zavrsni_rezultat(igrajer, ploca), None | |
return value(ploca), None | |
return max((value(napravi_potez(m, igrajer, list(ploca))), m) for m in moves) | |
MAX_VALUE = sum(map(abs, TEZINE_PLOCE)) | |
MIN_VALUE = -MAX_VALUE | |
def zavrsni_rezultat(igrajer, ploca): | |
diff = rezultat(igrajer, ploca) | |
if diff < 0: | |
return MIN_VALUE | |
elif diff > 0: | |
return MAX_VALUE | |
return diff | |
def minimax_searcher(depth, evaluate): | |
def strategy(igrajer, ploca): | |
return minimax(igrajer, ploca, depth, evaluate)[1] | |
return strategy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment