minimax

MiniMax with Alpha Beta Pruning for Othello not working

穿精又带淫゛_ 提交于 2019-12-13 02:37:16
问题 I have the following implementation of a alpha beta minimax for an othello (reversi) game. Somehow, this never really returns the proper action to take. It seems to return the default action I put in the function (0, 0) and the secondary value of -32768, which means it got pruned at the MAX subroutine. Any tips on what I can improve with this and how I can fix this problem? Note: I've identified the successors being returned properly for the most part. The max depth for now is 8. Computer

GKMinmaxStrategist modifies model after return of best move

試著忘記壹切 提交于 2019-12-12 05:14:35
问题 I implemented GKGameModel, GKGameModelPlayer and GKGameModelUpdate protocols in my corresponding classes. After I ask for best move strategist changes my model's board. I understand how it works, making copies of model and tried all moves, but I thought that my "main" model (from copies are made) won't be affected. Here is what I have: let strategist = GKMinmaxStrategist() strategist.maxLookAheadDepth = 0 strategist.randomSource = GKRandomSource() //my model. game is my auxiliary class,

How to call a minimax method(with alpha beta pruning) properly

南笙酒味 提交于 2019-12-12 03:38:50
问题 This is my minimax method which implements alpha beta pruning and memoization: public int[] newminimax499(int a, int b){ int bestPos=-1; int alpha= a; int beta= b; int currentScore; //boardShow(); String stateString = ""; for (int i=0; i<state.length; i++) stateString += state[i]; int[] oldAnswer = oldAnswers.get(stateString); if (oldAnswer != null) return oldAnswer; if(isGameOver2()!='N'){ int[] answer = {score(), bestPos}; oldAnswers.put (stateString, answer); return answer; } else{ for(int

Where's error in implementation of minimax algorithm?

让人想犯罪 __ 提交于 2019-12-12 02:19:21
问题 There is one little problem with it's implementation for a Tic-Tac-Toe game. For the following combination: ['x', 'o', 'e', 'o', ' e', 'e', 'e', ' e', 'e'] the best choice would be ['x', 'o', 'e', 'o', ' x', 'e', 'e', ' e', 'e'] but it returns as I suppose the nearest suitable one: ['x', 'o', 'x', 'o', ' e', 'e', 'e', ' e', 'e'] And in this case AI loses. Here is the code: var board = ['x', 'o', 'e', 'o', 'e', 'e', 'e', 'e', 'e']; var signPlayer = 'o'; var signAI = (signPlayer === 'x') ? 'o'

Minimax python - how to efficiently find alternating max and mins in a tree

99封情书 提交于 2019-12-12 00:45:40
问题 The following code I'm using to minimax a tree looks awful. Surely there is a way to simplify this and use a function instead of a int.MaxValue if depth%2==1: min = 9999 for child in currentRoot.children: if child.score < min: min = child.score currentRoot.score = min else: max = -9999 for child in currentRoot.children: if child.score > max: max = child.score currentRoot.score = max return currentRoot.score 回答1: First, don't use min and max for variable names as this shadows the built-in

Haskell Recursive Minimax Tree

你离开我真会死。 提交于 2019-12-10 10:49:18
问题 I'm trying to write a Tic Tac Toe program in Haskell, using the minimax algorithm. I constructed my own "Rose a" data type as follows: data Rose a = a :> [Rose a] This is the data type in which I want to 'store' my minimax tree. I understand how the minimax algorithm works, but can't seem to implement it in a recursive function. minimax :: Player -> Rose Board -> Rose Int minimax p (r :> []) | hasWinner r == Just p = 1 :> [] | hasWinner r == Just (nextPlayer p) = (-1) :> [] | otherwise = 0 :>

Converting Minimax to Negamax (python)

耗尽温柔 提交于 2019-12-10 10:44:19
问题 I'm making an Othello player, and implemented a minimax algorithm with alpha-beta pruning. Then I did a bunch of research on the best ones online and keep hearing about a "negamax" algorithm that they all use. It seems like most people think negamax is faster than minimax (i think because it doesn't switch between min and max player?), so I'd like to turn my minimax algorithm into negamax if that's not too difficult. I was wondering if people had any insight on how much faster using negamax

How to get actual move rather than move value from mini max algorithm

纵饮孤独 提交于 2019-12-10 10:39:52
问题 I am currently writing a minimax algorithm with alpha beta pruning for Chess. From all the examples I have seen, minimax algorithm will return an int value that represents that best score or board state that will result from the best move. My question is how can we return the best move that is associated with the score return value? For example, my alphabeta() in pseudo below ... public int alphabeta(int depth, Board b, int alpha, int beta, boolean maxPlayer) { if(depth == 0) return

How many threads are okay to use for tic-tac-toe using minimax?

谁说我不能喝 提交于 2019-12-09 16:53:42
问题 Let's take a 5x5 tic-tac-toe as an example. Let's say it's my AI's turn. Then, I make 25 moves (at each cell basically, of course, if it's a legal move), create a thread for each move (25 threads total (at most)), call a minimax function on each made move, then when all results come from each thread, compare the scores and choose the move with the best score. Here are my questions: Is it efficient to use 25 threads? What does using 25 threads mean? Is it 25 times faster (most likely not)?

Using minimax search for card games with imperfect information

﹥>﹥吖頭↗ 提交于 2019-12-09 09:30:38
问题 I want to use minimax search (with alpha-beta pruning), or rather negamax search, to make a computer program play a card game. The card game actually consists of 4 players. So in order to be able to use minimax etc., I simplify the game to "me" against the "others". After each "move", you can objectively read the current state's evaluation from the game itself. When all 4 players have placed the card, the highest wins them all - and the cards' values count. As you don't know how the