Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with Minimax Algorithm  RSS feed

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to implement a minimax algorithm based on this pseudo code below. Could anyone tell me if this pseudo code is correct, because I'm haivng a hell of a time getting it to work. Some things I don't get are:

1. In the MinMove function why do they use move > best_move (identical to max move). Shouldn't the min move try to minimiz max's advantage, thus it should be < (or better yet <= )?

2. Assuming best_move and move are integer values, how can I assign a null type value or -infinity / +inifity? Since minimax starts evaluating from bottom up, say for example it is evaluating the last MaxMove (very top of tree - root) and it's default best_move value = 0, and the move value returned is -1, but there are currently no moves returned by MaxMove, so it must return the -1 move, but will not since it is less than zero. What if there are a couple different moves that return a loss (-1) and MaxMove will not include any of them because they are less than zero, thus causing the program to error out.

3. Why is the if -> GameEnded function not also included in the MinMove?

Sorry for the all the questions, but I've been at this for a long time, and most online resources really suck. All I'm after is an algorithm that is actually correct, and I'm almost positive this one is not.

I found it at this site in case anyone is interested:
http://ai-depot.com/LogicGames/MiniMax.html


[ August 12, 2006: Message edited by: Bob Zoloman ]
 
Bob Zoloman
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it to work, in case anyones interested this is the pseudo code that works for me.


[ August 12, 2006: Message edited by: Bob Zoloman ]
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!