Hãy để tôi bắt đầu bằng cách nói rằng câu hỏi này có thể được trả lời bởi các trình thuật sĩ AI không có kinh nghiệm Prolog.Thực hiện Minimax trong "Lập trình Prolog cho Trí tuệ nhân tạo" - min_to_move/1 và max_to_move/1 là gì?
Các Prolog Programming for Artificial Intelligence cuốn sách tuyệt vời có khá ngắn gọn và thông minh thực hiện minimax này:
minimax(Pos, BestSucc, Val) :-
moves(Pos, PosList), !, % Legal moves in Pos produce PosList
best(PosList, BestSucc, Val)
;
staticval(Pos, Val). % Pos has no successors: evaluate statically
best([ Pos], Pos, Val) :-
minimax(Pos, _, Val), !.
best([Pos1 | PosList], BestPos, BestVal) :-
minimax(Pos1, _, Val1),
best(PosList, Pos2, Val2),
betterof(Pos1, Val1, Pos2, Val2, BestPos, BestVal).
betterof(Pos0, Val0, Pos1, Val1, Pos0, Val0) :- % Pos0 better than Pos1
min_to_move(Pos0), % MIN to move in Pos0
Val0 > Val1, ! % MAX prefers the greater value
;
max_to_move(Pos0), % MAX to move in Pos0
Val0 < Val1, !. % MIN prefers the lesser value
betterof(Pos0, Val0, Pos1, Val1, Pos1, Val1). % Otherwise Pos1 better than Pos0
Tuy nhiên, tác giả đã không đi đến nhiều thời gian trong việc mô tả nó và tôi còn lại để tự hỏi điều gì min_to_move/1
và max_to_move/1
là .
Có ai có thể giải thích cho tôi không?
Cảm ơn trước!