minimax

Conversion of minimax with alpha beta pruning to negamax

﹥>﹥吖頭↗ 提交于 2019-11-30 15:15:23
I've written a minimax algorithm with alpha beta pruning for the game Checkers, and now I'm trying to rewrite it using the negamax approach. I'm expecting the two to be equivalent, since negamax is just a technique to write the minimax. But for some reason my two algorithms behave differently. When I run them both on the same input, the negamax version seems to evaluate more states, so I think something must be wrong with the alpha beta pruning. The code below shows both algorithms ( minimax and negamax functions), and at the bottom the play function from which I call them. The evaluate

Alpha-beta pruning for Minimax

只谈情不闲聊 提交于 2019-11-30 13:53:24
问题 I have spent a whole day trying to implement minimax without really understanding it. Now, , I think I understand how minimax works, but not alpha-beta pruning. This is my understanding of minimax: Generate a list of all possible moves, up until the depth limit. Evaluate how favorable a game field is for every node on the bottom. For every node, (starting from the bottom), the score of that node is the highest score of it's children if the layer is max. If the layer is min, the score of that

How exactly does minimax recursion work?

落爺英雄遲暮 提交于 2019-11-30 10:17:02
So I was looking up Mini-max for a Tic-Tac-Toe Game, but couldn't understand how the recursion worked? Okay, so basically here are my questions: How does minimax know whose turn is it? Whats the best way to indicate the player whose turn it is generating? How do you generate possible moves? How do you know when you are at a terminal node, and how do you generate the terminal nodes? For example in this Pseudo-code function integer minimax(node, depth) if node is a terminal node or depth <= 0: return the heuristic value of node α = -∞ for child in node: # evaluation is identical for both players

Alpha-beta pruning for Minimax

可紊 提交于 2019-11-30 08:47:29
I have spent a whole day trying to implement minimax without really understanding it. Now, , I think I understand how minimax works, but not alpha-beta pruning. This is my understanding of minimax: Generate a list of all possible moves, up until the depth limit. Evaluate how favorable a game field is for every node on the bottom. For every node, (starting from the bottom), the score of that node is the highest score of it's children if the layer is max. If the layer is min, the score of that node is the lowest score of it's children. Perform the move that has the highest score if you are

Return bestMove in minimax algorithm for tictactoe

柔情痞子 提交于 2019-11-30 04:25:36
I have tried to code the minimax algorithm for tic-tac-toe given in Russel Norvig's book on Artificial Intelligence. It had everything except that the way to return the bestMove to the user. I am trying hard to return the bestMove, but cannot decide when to choose the bestMove. Help, anyone? moveT MiniMax(stateT state) { moveT bestMove; max_move(state,bestMove); return bestMove; } int max_move(stateT state,int & bestMove) { int v = -10000; if(GameIsOver(state)) { return EvaluateStaticPosition(state); } vector<moveT> moveList; GenerateMoveList(state, moveList); int nMoves = moveList.size(); for

How exactly does minimax recursion work?

China☆狼群 提交于 2019-11-29 15:19:58
问题 So I was looking up Mini-max for a Tic-Tac-Toe Game, but couldn't understand how the recursion worked? Okay, so basically here are my questions: How does minimax know whose turn is it? Whats the best way to indicate the player whose turn it is generating? How do you generate possible moves? How do you know when you are at a terminal node, and how do you generate the terminal nodes? For example in this Pseudo-code function integer minimax(node, depth) if node is a terminal node or depth <= 0:

Tic-Tac-Toe minimax algorithm doesn't work with 4x4 board

本秂侑毒 提交于 2019-11-29 11:13:26
So I've been working on this project for the past 3 weeks now. I managed to get the minimax function to work early on for a 3x3 board, however problems started arising when I tried using it for a 4x4 board, namely Java heap space errors. Since then, with the help of Alpha beta pruning, I've managed to bring down the number of required minimax calls within the minimax function from aprox. 59000 to 16000 to 11000 and then finally to 8000 calls(This is assuming an initial minimax call for a board with one slot already filled). The problem now however, is that the method just keeps running for 4x4

Return bestMove in minimax algorithm for tictactoe

我们两清 提交于 2019-11-29 01:11:34
问题 I have tried to code the minimax algorithm for tic-tac-toe given in Russel Norvig's book on Artificial Intelligence. It had everything except that the way to return the bestMove to the user. I am trying hard to return the bestMove, but cannot decide when to choose the bestMove. Help, anyone? moveT MiniMax(stateT state) { moveT bestMove; max_move(state,bestMove); return bestMove; } int max_move(stateT state,int & bestMove) { int v = -10000; if(GameIsOver(state)) { return EvaluateStaticPosition

Tic-Tac-Toe minimax algorithm doesn't work with 4x4 board

帅比萌擦擦* 提交于 2019-11-28 04:38:44
问题 So I've been working on this project for the past 3 weeks now. I managed to get the minimax function to work early on for a 3x3 board, however problems started arising when I tried using it for a 4x4 board, namely Java heap space errors. Since then, with the help of Alpha beta pruning, I've managed to bring down the number of required minimax calls within the minimax function from aprox. 59000 to 16000 to 11000 and then finally to 8000 calls(This is assuming an initial minimax call for a

Minimax explained for an idiot

无人久伴 提交于 2019-11-27 14:44:16
问题 I've wasted my entire day trying to use the minimax algorithm to make an unbeatable tictactoe AI. I missed something along the way (brain fried). I'm not looking for code here, just a better explanation of where I went wrong. Here is my current code (the minimax method always returns 0 for some reason): from copy import deepcopy class Square(object): def __init__(self, player=None): self.player = player @property def empty(self): return self.player is None class Board(object): winning_combos