- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在为国际象棋游戏制作 AI。
到目前为止,我已经成功实现了 Alpha-Beta Pruning Minimax 算法,它看起来像这样(来自维基百科):
(* Initial call *)
alphabeta(origin, depth, -∞, +∞, TRUE)
function alphabeta(node, depth, α, β, maximizingPlayer)
if depth = 0 or node is a terminal node
return the heuristic value of node
if maximizingPlayer
for each child of node
α := max(α, alphabeta(child, depth - 1, α, β, FALSE))
if β ≤ α
break (* β cut-off *)
return α
else
for each child of node
β := min(β, alphabeta(child, depth - 1, α, β, TRUE))
if β ≤ α
break (* α cut-off *)
return β
因为这花费了太多的时间复杂度(一棵一棵地遍历所有树),我遇到了一个叫做 "History Heuristic" 的东西。 .
原始论文中的算法:
int AlphaBeta(pos, d, alpha, beta)
{
if (d=0 || game is over)
return Eval (pos); // evaluate leaf position from current player’s standpoint
score = - INFINITY; // preset return value
moves = Generate(pos); // generate successor moves
for i=1 to sizeof(moves) do // rating all moves
rating[i] = HistoryTable[ moves[i] ];
Sort( moves, rating ); // sorting moves according to their history scores
for i =1 to sizeof(moves) do { // look over all moves
Make(moves[i]); // execute current move
cur = - AlphaBeta(pos, d-1, -beta, -alpha); //call other player
if (cur > score) {
score = cur;
bestMove = moves[i]; // update best move if necessary
}
if (score > alpha) alpha = score; //adjust the search window
Undo(moves[i]); // retract current move
if (alpha >= beta) goto done; // cut off
}
done:
// update history score
HistoryTable[bestMove] = HistoryTable[bestMove] + Weight(d);
return score;
}
所以基本上,这个想法是为之前的“移动”跟踪哈希表或字典。
现在我对这里的“移动”意味着什么感到困惑。我不确定它是字面上指的是单个 Action 还是每次 Action 后的整体状态。
例如,在国际象棋中,这个哈希表的“键”应该是什么?
个人移动,例如(皇后到位置 (0,1))或(马到位置 (5,5))?
还是棋盘走单后的整体状态?
如果 1 是这种情况,我猜在将“移动”记录到我的历史表中时没有考虑其他棋子的位置?
最佳答案
我认为在线提供的原始论文(The History Heuristic and Alpha-Beta Search Enhancements in Practice,Jonathan Schaeffer)清楚地回答了这个问题。在论文中,作者将移动定义为棋盘上的 2 个索引(从正方形和到),使用 64x64 表(实际上,我认为他使用位移和单个索引数组)来包含移动历史。
作者比较了所有可用的移动排序方式,并确定 hh 是最好的。如果当前的最佳实践已经建立了移动排序的改进形式(超越 hh + 换位表),我也想知道它是什么。
关于algorithm - 如何在 alpha-beta minimax 中使用 "History Heuristic"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19944529/
我有一个非常简单的问题。 我正在研究 8 拼图(8 个数字(从 1 到 8)+ 空白(=0)) 在计算汉明距离(错误位置的数字)和曼哈顿距离(开始和最终位置之间的水平+垂直距离)时,我应该考虑“空白”
如何在没有节点或单元的无网格二维平面上实现 A* 算法?我需要物体绕过目标途中相对较多的静态和移动障碍物。 我当前的实现是在对象周围创建八个点,并将它们视为可能是对象潜在位置的假想相邻正方形的中心。然
我刚刚研究了heuristic functions,但是找不到关于黑白棋启发式函数的想法(Othello),我只需要一个很好的想法来对板的某些状态进行评分 我想到了: 计数移动次数 盘数 并计算转角处
我正在使用这里看到的 A 星算法(取自 http://code.activestate.com/recipes/578919-python-a-pathfinding-with-binary-heap
我正在研究前瞻性规划启发式 hmax、hadd 和 hff,我在网上找到了一些资源,但我真的不明白它们是如何工作的。 到目前为止,我找到的资源如下: http://icaps09.uom.gr/tut
我正在尝试实现 D*-Lite 寻路算法,如 Koenig 和 Likhachev 在 2002 年针对基于网格的导航图的文章中所述。 但我在那篇论文中没有看到任何启发式函数。那么,我应该选择哪些功能
我正在开发一种 A* 算法,旨在解决传教士和食人者问题。我不明白的是启发式算法是如何使搜索的节点数少于 Dikstras 算法的。 我理解程序会根据启发式值+当前值来确定可能的值,从而根据最佳优先进行
This is my project佛罗伦萨大学人工智能类(class)。我必须解决一个经典游戏:带有 8 和 15 格的滑动拼图。这是我对通用图搜索算法的实现: public abstract cl
我有一组 N 个项目,我知道它们之间的距离。每个元素都有成本,我有预算。我应该完成以下任务:假设我将一个项目放入篮子中,篮子中的下一个项目将是与第一个(在预算约束下)距离最大的项目,第三个项目将是距离
我需要一些帮助来为以下问题找到一个好的启发式方法: You are given an R-by-C grid and a six-sided die. Let start and end be two
我正在为国际象棋游戏制作 AI。 到目前为止,我已经成功实现了 Alpha-Beta Pruning Minimax 算法,它看起来像这样(来自维基百科): (* Initial call *) al
git 2.9 版本带有一个实验性差异算法 --compaction-heuristic。我已经设置了 git 和 git gui 来使用它。 但是我不知道如何配置 gitk 来使用这个选项。我知道
我使用 Prolog (Swipl) 实现了 15 拼图游戏。我已经使用曼哈顿启发式实现了 A* 搜索,但现在我需要添加汉明启发式。 你知道如何实现吗? :- op(400,yfx,'@'). res
我正在尝试使事务成为 Spring 集成的整个流程,该流程从一个到 IBM MQ 队列的适配器开始,然后我们有一个带有 ActiveMQ 队列的复杂流程,我得到了一个 com.atomikos。 ic
背景:我目前正在研究原始 A Star 算法的 8 拼图实现,并将其与略微修改的算法进行比较,该算法旨在改进节点扩展(使用附加信息,当然,A Star 在同样知情的单向搜索中具有被证明是最佳的)。节点
http://lab.arc90.com/experiments/readability/是一个非常方便的工具,可以以非常可读的方式查看杂乱的报纸、期刊和博客页面。它通过使用一些启发式方法并查找网页的
我是一名优秀的程序员,十分优秀!