AI

来源:互联网 发布:工业数据采集 编辑:程序博客网 时间:2024/04/29 19:55

  • Cost
  • Parity
    • Seach Algorithms Informed Search
    • Search Algorithms Uniformed Search
    • Heuristics for single-agent
    • Minimax
    • Heuristics for adverserial games
    • Alpha-beta pruning for minimax

Cost

f(n)=g(n)+h(n)

– g(n) Cost from root to node n;
– h(n) Estimated cost from n to goal.

* Uniformed Search: ifh(n)=0;
* Informed Search: if h(n)0;

Parity

中文名:奇偶校验
不是所有initial State都能到达goal State。Parity的算法结果帮助判断用不用执行Search Algorithms:
0: puzzle state has even parity
1: puzzle state has odd parity
当Initial State的Parity == Goal State的parity,才用执行Search Algorithms.

  • Actions:
    • Up(-3), Down (+3), Left (-1), Right (+1)
  • States:
    • 用Recursion(或for loop) generate 关于 当前 State的 空格的所有可能的states, 即以空格为主要研究对象以其他数字为辅助研究对象。如上面左图 1[ref],空格需要通过判断可行的Actions,并运行这些Actions,recurlively 得到:
      • 当空格向上:3 与 空格 Swap
      • 当空格向下:8 与 空格 Swap
      • 当空格向左:6 与 空格 Swap
      • 当空格向右:可以用格子的位置index(0,1,2…8)判断(如上面右图),当空格在第5格时,空格不能向右移动。

在使用Search Algorithms去寻找可行的States的解法,需要以State为Nodes去建立一个Graph。可以用Adjacent matrix 或 Adjacent List. Node 的Parent为State的上一个状态。一个为Parent node 的State, 可以有很多可以走的States 。继续上面一个例子:

BFS, DFS 和 A* 等Search Algorithms 能够帮助我们以起始的State找到相关的Path去到达goal的State。但在这过程中,去判断从一个State到下一个State的判断依据不同(对于非Root的Node,设Swap一次的Cost = 1;Root的Cost=0):

  • BFS:如果不用Cost,则只是使用FIFO的List便可。为了优化BFS,使用 Linked List(有Priority Queue作用, 最前面的为Cost累计最少的State),因为以Cost当Weight,使用 f(n) = g(n) + h(n) 的式, 是 Informed Cost Search

  • 双向BFS:相似的While loop判断;并用2个Priority Queues,一个从起始点为Initial State往Goal State方向Search,另一个相反,从Goal Sate为Initial State 向起始点放向Search。类似题目

  • DFS: 不看Cost,一有可行的State就移步到这个可行的State (Stack,最前面的为最后加进去的Sate),速度最慢

  • A*: 使用 f(n) = g(n) + h(n) 的式子,比BFS好, 是 Informed Cost Search

  • Iterative-Deepening A* (IDA*): 和A*相似,是A*的优化版本

* BFS,DFS 与 A* 和 IDA* 区别 (OS:喜欢这篇总结)


Heuristics for single-agent

Minimax

Heuristics for adverserial games

Alpha-beta pruning for minimax

原创粉丝点击