minimax

Tic Tac Toe C++ algorithm debugging help

送分小仙女□ 提交于 2020-01-05 07:46:44
问题 Please help me understand why this isn't working. I don't know if there is a bug in my code, or whether my algorithm is fundamentally logically flawed. My algorithm is based on minimax, but I've forgone a heuristic evaluation function for a more simple technique. Because of the simplicity of plain 3x3 tic tac toe, I just want to calculate all possible game outcomes for each potential move, and select the one with the highest 'score'. I create a 'top level' vector of valid moves as well as a

Minimax/ Alpha beta pruning Move Ordering?

蓝咒 提交于 2020-01-02 07:58:30
问题 I've read (for example, http://radagast.se/othello/Help/order.html) that searching on the best moves at each level first (which can be found using iterative deepening) makes the search go much faster. How would one go about searching on the best moves possible without using too much additional memory and cpu time? 回答1: There are basically two strategies: Static move ordering Dynamic move ordering Dynamic move ordering uses information from previous searches, either because you transpose into

C++ minimax function

纵然是瞬间 提交于 2019-12-30 11:06:18
问题 I have searched Google and Stackoverflow for this question, but I still don't understand how a minimax function works. I found the wikipedia entry has a pseudocode version of the function: 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 α = max(α, -minimax(child, depth-1)) return α Several other minimax functions I found with Google are basically the same

C++ minimax function

蓝咒 提交于 2019-12-30 11:04:20
问题 I have searched Google and Stackoverflow for this question, but I still don't understand how a minimax function works. I found the wikipedia entry has a pseudocode version of the function: 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 α = max(α, -minimax(child, depth-1)) return α Several other minimax functions I found with Google are basically the same

C++ minimax function

a 夏天 提交于 2019-12-30 11:04:16
问题 I have searched Google and Stackoverflow for this question, but I still don't understand how a minimax function works. I found the wikipedia entry has a pseudocode version of the function: 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 α = max(α, -minimax(child, depth-1)) return α Several other minimax functions I found with Google are basically the same

MiniMax Algorithm for Tic Tac Toe failure

杀马特。学长 韩版系。学妹 提交于 2019-12-25 04:56:21
问题 I'm trying to implement a minimax algorithm for tic tac toe with alpha-beta pruning. Right now I have the program running, but it does not seem to be working. Whenever I run it it seems to input garbage in all the squares. I've implemented it so that my minimax function takes in a board state and modifies that state so that when it is finished, the board state contains the next best move. Then, I set 'this' to equal the modified board. Here are my functions for the minimax algorithm: void

Return a move from alpha-beta

无人久伴 提交于 2019-12-24 08:45:07
问题 I'm trying to use the alpha-beta minimax pruning algorithm to return a valid move from my board. The algorithm returns the correct value, but I have no idea how I would return the move as well. In the case of this code, I would want to return the child in get_successor_states when the value of bestValue is more than the current alpha. I thought about returning two values at the end of the max and min like return bestValue, child but I have no idea how I would get that to work with the other

Blackjack minimax algorithm

独自空忆成欢 提交于 2019-12-24 05:12:43
问题 I am implementing a blackjack game with minimax tree which calculates the probabilities and play automatically depend on this probabilities. Assume that, we play with 1 deck and the first game dealer takes : ' 5 ' and player takes ' 5 7 ' so the total score is 12 for player. In this case, first I am trying to check all possible probabilities for player's stand decision. If player stands : My remain cards in deck like this : Structure of deck(K,V) K : card number, V: count of card {1: 4, 2: 4,

simplest MiniMax algorithm for TicTacToe AI in Java

时光毁灭记忆、已成空白 提交于 2019-12-24 04:51:50
问题 I was trying to get a grasp of MiniMax algorithm, and have read up on it. My initial approach was to implement a simple MiniMax algorithm, and then to add alpha-beta pruning. However this is my current code: public int miniMax(char[] node, int playerNum) { int victor = checkWin(node); // returns 0 if game is ongoing, 1 for p1, 2 for p2, 3 for tie. if(victor != 0) //game over . return score(victor); if(playerNum == 2) //AI { int bestVal = Integer.MIN_VALUE; int bestSpot = 0; for(int i = 0; i <

simplest MiniMax algorithm for TicTacToe AI in Java

时光毁灭记忆、已成空白 提交于 2019-12-24 04:51:01
问题 I was trying to get a grasp of MiniMax algorithm, and have read up on it. My initial approach was to implement a simple MiniMax algorithm, and then to add alpha-beta pruning. However this is my current code: public int miniMax(char[] node, int playerNum) { int victor = checkWin(node); // returns 0 if game is ongoing, 1 for p1, 2 for p2, 3 for tie. if(victor != 0) //game over . return score(victor); if(playerNum == 2) //AI { int bestVal = Integer.MIN_VALUE; int bestSpot = 0; for(int i = 0; i <