Last year I wrote a post about AI in reversi using minimax algorithm with alpha beta pruning. However, it said nothing about the implementation. So, for you guys who already grabbed the idea of minimax but still having some troubles in implementing it, here's a pseudocode that might help you with. It's not something that I wrote by myself, but the idea is somewhat similar.
begin
best_score = -infinity;
Gt_generate_moves(current_mimx_data,moves_list);
for (i = 0 to moves_list.num_moves-1) do
new_board = board;
Gt_move(board, moves_list[i],the_unmove);
minimax(board, the_score,the_move);
Gt_unmove(board,the_unmove);
if (the_score > best_score) then
best_score = the_score;
best_move = moves_list[i];
if (best_score > best_opposing_score) then
cut;/* the opponent will not allow you to reach this node*/
endif
endif
enddo
chosen_move = best_move;
Gt_evaluate(current_mimx_data,chosen_score,best_score);
end.
1 comments:
Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the Webcam, I hope you enjoy. The address is http://webcam-brasil.blogspot.com. A hug.
Post a Comment