Minimax

Minimax (kadhang kala MinMax, MM[1] utawa saddle point[2]) minangka aturan keputusan sing digunakake ing intelijen buatan, teori keputusan, teori game, statistik, lan filsafat kanggo minimalake kemungkinan kerugian kanggo skenario kasus paling ala (kerugian maksimal). Nalika ngatasi keuntungan, diarani "maksimal" - kanggo nggedhekake bathi minimal. Originally diformulasikaken kanggo teori game nol-jumlah n-player, kalebu loro kasus nalika pemain njupuk gerakan alternatif lan gerakane bebarengan, uga ditambahake menyang game sing luwih rumit lan nggawe keputusan umum yen durung mesthi.

Pseudocode

Pseudocode kanggo algoritma minimax winates jerone iku kaya ing ngisor iki:

```function minimax(node, depth, maximizingPlayer) is
if depth = 0 or node is a terminal node then
return the heuristic value of node
if maximizingPlayer then
value := −∞
for each child of node do
value := max(value, minimax(child, depth − 1, FALSE))
return value
else (* minimizing player *)
value := +∞
for each child of node do
value := min(value, minimax(child, depth − 1, TRUE))
return value
```
```(* Initial call *)
minimax(origin, depth, TRUE)
```