, , " ", , ( "", k), , , , . , , minimax , :
let rec minimax node depth alpha beta k =
if depth = 0 || nodeIsTerminal node then
k (heuristicValue node)
else
match node.PlayerToMakeNextChoice with
| PlayerOneMakesNextChoice ->
k (takeMax (getChildren node) depth alpha beta)
| PlayerTwoMakesNextChoice ->
k (takeMin (getChildren node) depth alpha beta)
" ", , - :
let a = minimax ...
let b = f a
let c = g b
c
- :
minimax ... (fun a ->
let b = f a
let c = g b
c
)
? a minimax, a - , minimax. - , , minimax , , a.
, , :
| firstChild :: remainingChildren ->
minimax firstChild (depth - 1) alpha beta (fun minimaxResult ->
let newAlpha = [alpha; minimaxResult] |> List.max
if beta < newAlpha then newAlpha
else takeMax remainingChildren depth newAlpha beta
)
, , : minimax CPS, takeMin takeMax - . .
, takeMax. : k , "" , k:
and takeMax children depth alpha beta k =
match children with
| [] -> k alpha
| firstChild :: remainingChildren ->
minimax firstChild (depth - 1) alpha beta (fun minimaxResult ->
let newAlpha = [alpha; minimaxResult] |> List.max
if beta < newAlpha then k newAlpha
else takeMax remainingChildren depth newAlpha beta k
)
, , :
let minimax ... k =
...
match node.PlayerToMakeNextChoice with
| PlayerOneMakesNextChoice ->
takeMax (getChildren node) depth alpha beta k
, ? , , , k, . k takeMax. ?
, , " , k", . - " , k ". , k , .
, , CPS , . , - . , fun minimaxResult -> ..., . , .
: , - , .