iterative-deepening

How to implement a transposition table for connect 4?

帅比萌擦擦* 提交于 2021-01-27 08:00:07
问题 I'm making a connect 4 AI in python, and I'm using minimax with iterative deepening and alpha beta pruning for this. For greater depths it's still quite slow, so I wanted to implement a transposition table. After reading up on it I think i get the general idea but i haven't been able to quite make it work. Here's part of my code: (the maximizing part of the minimax): if(isMaximizing): maxEval = -99999999999 bestMove = None # cache.get(hash(board)) Here's where i'd check to see if the hash is

How to implement a transposition table for connect 4?

寵の児 提交于 2021-01-27 07:56:04
问题 I'm making a connect 4 AI in python, and I'm using minimax with iterative deepening and alpha beta pruning for this. For greater depths it's still quite slow, so I wanted to implement a transposition table. After reading up on it I think i get the general idea but i haven't been able to quite make it work. Here's part of my code: (the maximizing part of the minimax): if(isMaximizing): maxEval = -99999999999 bestMove = None # cache.get(hash(board)) Here's where i'd check to see if the hash is

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

How to store visited states in iterative deepening / depth limited search?

左心房为你撑大大i 提交于 2019-12-23 21:50:34
问题 Update: Search for the first solution. for a normal Depth First Search it is simple, just use a hashset bool DFS (currentState) = { if (myHashSet.Contains(currentState)) { return; } else { myHashSet.Add(currentState); } if (IsSolution(currentState) return true; else { for (var nextState in GetNextStates(currentState)) if (DFS(nextState)) return true; } return false; } However, when it becomes depth limited, i cannot simply do this bool DFS (currentState, maxDepth) = { if (maxDepth = 0) return

Depth First Iterative deepening algorithm returning no results (in java)

非 Y 不嫁゛ 提交于 2019-12-11 18:18:57
问题 I have a search algorithm that is supposed to parse the entire tree, find all results that could match a search query, and return them all as a list. I realize this isn't quite the point of the algorithm, but I'm doing this as a test with breadth first and depth first searches to see what is fastest by timing them. The other two searches work as intended, but when I enter the same search information as my goal for the DFID search i get an empty list. So I know my data is right, just something

Writing a DFS with iterative deepening without recursion

狂风中的少年 提交于 2019-12-08 10:28:34
问题 So currently i have a DFS with the following pseudocode procedure DFS(Graph,source): create a stack S push source onto S mark source while S is not empty: pop an item from S into v for each edge e incident on v in Graph: let w be the other end of e if w is not marked: mark w push w onto S How do I alter this function to accept a third argument that limits the depth of the search? 回答1: Let Node a structure for each node of the graph, add a field called level and then: procedure DFS(Graph

Minimax/ Alpha beta pruning Move Ordering?

青春壹個敷衍的年華 提交于 2019-12-06 00:11:03
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? There are basically two strategies: Static move ordering Dynamic move ordering Dynamic move ordering uses information from previous searches, either because you transpose into the same position again, or you have already reached the position in a previous less thorough search. That

Chess: high branching factor

旧时模样 提交于 2019-12-03 02:29:30
问题 I'm trying to develop a simple chess engine, but I'm struggling with its performance. I've implemented Negamax with alpha-beta pruning and iterative deepening (without any additional heuristics), but I'm unable to get reasonable search time beyond 3-4th ply. Here is an excerpt from my program's log from the beginning of the game: 2013-05-11 18:22:06,835 [9] INFO CoevolutionaryChess.Engine.MoveSearchers.NegamaxMoveSearcher [(null)] - Searching at depth 1 2013-05-11 18:22:06,835 [9] DEBUG

Chess: high branching factor

旧时模样 提交于 2019-12-02 16:01:26
I'm trying to develop a simple chess engine, but I'm struggling with its performance. I've implemented Negamax with alpha-beta pruning and iterative deepening (without any additional heuristics), but I'm unable to get reasonable search time beyond 3-4th ply. Here is an excerpt from my program's log from the beginning of the game: 2013-05-11 18:22:06,835 [9] INFO CoevolutionaryChess.Engine.MoveSearchers.NegamaxMoveSearcher [(null)] - Searching at depth 1 2013-05-11 18:22:06,835 [9] DEBUG CoevolutionaryChess.Engine.MoveSearchers.NegamaxMoveSearcher [(null)] - Leaves searched: 28 2013-05-11 18:22

Iterative deepening in common lisp

白昼怎懂夜的黑 提交于 2019-12-01 03:24:24
问题 I've written an iterative deepening algorithm, it works except when I add cycle checking, the algorithm returns a deeper solution than it should. But when I don't check for cycles it does work correctly, but it takes too long. Can anyone please spot the bug? (defun rec-depth-limited (problem node cutoff closed) (if (= cutoff 0) (if (funcall (problem-goalp problem) node) node) (if (visited-p node closed) nil (progn ;; when i remove the next line, it works correctly (setf (gethash (node-state