Neuron 101

Solving by search / Minimax

Türkçe

Plate19

Unit 2 · Topic 8 of 10

Minimax

Medium, 7 min, 7 steps

MAXMIN????31282461452
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 7 Tree

The game tree

At the root it is our turn, MAX plays: we have three moves. After each move the opponent MIN picks one of three replies. The squares at the bottom are the scores where the game ends; a high score is good for us.

Open in Colab
  1. def minimax(d, max_mi):
  2. if isinstance(d, int):
  3. return d
  4. v = [minimax(c, not max_mi)
  5. for c in d]
  6. if max_mi:
  7. return max(v)
  8. return min(v)
  9. agac = agac_uret(0)
  10. print(minimax(agac, True))