minimax

Minimax algorithm

泄露秘密 提交于 2019-12-04 11:44:26
问题 I have a simple question regarding the Minimax algorithm: for example for the tic-tac-toe game, how do I determine the utility function's for each player plays? It doesn't do that automatically, does it? I must hard-code the values in the game, it can't learn them by itself, does it? 回答1: No, a MiniMax does not learn. It is a smarter version of a brute-force tree search. 回答2: Typically you would implement the utility function directly. In this case the algorithm would not learn how to play

Minimax Algorithm Explanation

五迷三道 提交于 2019-12-04 10:29:36
I'm looking at this pseudocode for the Minimax algorithm: Function Minimax-Decision(state) returns an action ;inputs: state (current game state) ;'E' means element of, 'a' is the action return a E Actions(state) maximizing Min-Value(Result(a, state)) Function Max-Value(state) returns a utility value if Terminal-Test(state) then return Utility(state) v <-- -infinity for a, s in Successors(state) do v <-- Max(v, Min-Value(s)) return v Function Min-Value(state) returns a utility value if Terminal-Test(state) then return Utility(state) v <-- infinity for a, s in Successors(state) do v <-- Min(v,

Attempting to use continuation passing style to avoid stack overflow with minimax algorithm

大城市里の小女人 提交于 2019-12-04 09:08:06
Summary of my objective: Figure out how to use continuation-passing style to avoid a stack overflow when using an algorithm I believe cannot be made tail-recursive. Alternatively, find a way to make the function tail-recursive. Details: I am new to F# (and functional programming in general) and I am attempting to implement the minimax algorithm with alpha-beta pruning. This is an algorithm used to determine the best possible move for a two-player game. The pseudocode for the algorithm can be found here: https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning This is a resource I've found

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

半腔热情 提交于 2019-12-04 06:19:10
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)? What it depends on? On the computer, of course, but how can I know how many threads are okay to use based

NegaMax Algorithm and TicTacToe…What's wrong?

时光毁灭记忆、已成空白 提交于 2019-12-03 20:30:31
I am new to game tree algorithms, and i've tried to implement a simple tictactoe game which utilizes the NegaMax algorithm to evaluate tile scores for the computer AI player. However, the AI behaves not in a smart way (i can win all the time, because the AI does not block my moves), and i think i implemented the NegaMax algorithm wrongly. If anyone could help me with the following code, it would be great. I spent such a long time trying different things out, but i never got it to work. #include <stdlib.h> #include <stdio.h> #include <malloc.h> #include <limits.h> #include "game_board.h" /** *

Tic Tac Toe with Minimax: Computer sometimes losing when Player goes first; works otherwise

好久不见. 提交于 2019-12-03 16:42:22
I am working on a Minimax algorithm for unbeatable Tic Tac Toe. I need it to work both for when the Computer goes first as well as when the Player goes first. With the current version, the Computer will never lose when going first. However, it seems that Minimax never finds a best move (always returns -1 as the score) if the Player goes first. What is causing the Minimax score returned to be -1 for the Computer if the Player makes the first move? Example: board.addMark( 1, Mark2.PLAYER ); // add a 'PLAYER' mark to an arbitrary location Minimax.minimax( board, Mark2.COMPUTER ); // will always

Tic Tac Toe and Minimax - Creating an imperfect AI on a microcontroller

…衆ロ難τιáo~ 提交于 2019-12-03 11:56:08
I have created a Tic-Tac-Toe game on a microcontroller, including a perfect AI (perfect meaning that it doesn't lose). I did not use a minimax algorithm for that, just a little state machine with all possible and optimal moves. My problem now is that I wanted to implement different difficulties (Easy, Medium and Hard). The AI so far would be the hard one. So I've thought about how to do this the best way and ended up wanting to use the minimax algorithm but in a way that it calculates all the scores for all game positions so that I can also sometimes pick the second best score instead of the

Minimax algorithm

六月ゝ 毕业季﹏ 提交于 2019-12-03 07:16:56
I have a simple question regarding the Minimax algorithm: for example for the tic-tac-toe game, how do I determine the utility function's for each player plays? It doesn't do that automatically, does it? I must hard-code the values in the game, it can't learn them by itself, does it? No, a MiniMax does not learn. It is a smarter version of a brute-force tree search. Typically you would implement the utility function directly. In this case the algorithm would not learn how to play the game, it would use the information that you had explicitly hard-coded in the implementation. However, it would

Can a transposition table cause search instability

▼魔方 西西 提交于 2019-12-01 16:58:11
问题 I'm writing a chess engine and recently added a transposition table. When running a few tests, I found that although the search still returned the same best move, the value of the move (how good it is for the maximizing player) fluctuated. Is this normal behavior for a transposition table? I remember reading that a transposition table can cause search instability. Is this what that means? So is this a normal occurrence or a serious bug in my code? 回答1: Yes, transposition tables introduce

C++ minimax function

蹲街弑〆低调 提交于 2019-12-01 10:46:25
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 thing; I'm trying to implement this in C++, and this is what I have come up with so far: double miniMax