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

Sunday, April 20, 2008

Minimax Pseudocode

Sunday, April 20, 2008 Posted by Ismail Habib , 30 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)
best_score = -infinity;
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);
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*/
chosen_move = best_move;

Related post


  1. 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 A hug.

  2. Anonymous2:32 PM

    can this be us in mancala ???

  3. 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.

  4. 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.