Skip to content

Commit

Permalink
malo
Browse files Browse the repository at this point in the history
  • Loading branch information
Pikqi committed Aug 14, 2020
1 parent 4389c76 commit a388b9a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Connect4Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def igrajSledeciPotez():
# polja[y][mesto] = zuta
# poslednjiPotez = (y, mesto)

noviPotez = minimax(polja, 1, True, poslednjiPotez)[1]
noviPotez = minimax(polja, 2, True, poslednjiPotez)[1]

(a, b) = noviPotez

Expand Down Expand Up @@ -192,11 +192,12 @@ def minimax(polja1, depth, isMaximizing, poslednjiPotez1):
najboljiPotez = (y, i)
score = newScore
# score = max(score, minimax(polja2, depth - 1, not isMaximizing, poslednjiPotez1)[0])
najboljiPotezIScore = [score, najboljiPotez]
return najboljiPotezIScore

return [score, najboljiPotez]
if not isMaximizing:
najboljiPotez = (0,0)
score = math.inf
score = -math.inf
for i in range(0, 7):
y = nadjiSlobodnoY(i, polja1)
if y >=6:
Expand All @@ -206,9 +207,14 @@ def minimax(polja1, depth, isMaximizing, poslednjiPotez1):
polja2[y][i] = crvena
poslednjiPotez1 = (y, i)
newScore = minimax(polja2, depth-1, not isMaximizing, poslednjiPotez1)[0]
if newScore < score:
if newScore > score:
najboljiPotez = (y, i)
score = newScore
score = newScore

if score >= 100:
najboljiPotezIScore = [score, najboljiPotez]
return najboljiPotezIScore

return [score, poslednjiPotez1]
def nadjiScore(poslednjiPotez, polja):
# global poslednjiPotez, polja, pobedioJe
Expand Down Expand Up @@ -330,7 +336,7 @@ def brojIstihKriterijum(brojIstih):
return switch.get(brojIstih, 100)

def nadjiSlobodnoY (x, polja):
for i in range(5, 0, -1):
for i in range(5, -1, -1):
if polja[i][x] == 0:
return i
return 6
Expand Down

0 comments on commit a388b9a

Please sign in to comment.