yet another blog about computer, technology, programming, and internet

Sunday, April 20, 2008

Minimax Pseudocode

Sunday, April 20, 2008 Posted by Ismail Habib , 22 comments

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.

minimax(in game board, in best_opposing_score, out score chosen_score, out move chosen_move)
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.


Related post

22 comments:

  1. Anonymous2:32 PM

    can this be us in mancala ???

    ReplyDelete
  2. I was wondering this 'cause I didn't remember how Minimax Pseudocode are. Thanks for post this your blog it's very useful keep up the good work.

    ReplyDelete
  3. Technology can be viewed as an activity that forms or changes culture. Additionally, technology is the application of math, science, and the arts for the benefit of life as it is known. A modern example is the rise of communication technology, which has lessened barriers to human interaction and, as a result, has helped spawn new subcultures; the rise of cyberculture has, at its basis, the development of the Internet and the computer. Not all technology enhances culture in a creative way; technology can also help facilitate political oppression and war via tools such as guns. As a cultural activity, technology predates both science and engineering, each of which formalize some aspects of technological endeavor.

    Thanks
    Michael

    ReplyDelete
  4. The article attracted me and my friends to feel the same way, we will continue to follow your posts, try to post better articles, wish you success. I like this post because it contains a lot of useful information to read, maybe everyone will like it.
    abcya 4, io jogos for school, friv 4 school games 2019, cá koi mini

    ReplyDelete