Chapter 5 against search

Chapter V against search

A Game

definition

Target more competitive environment between the agent is a conflict, known as the confrontation search problem, also known as Game (Games).

Feature

  1. Complete information, determined, two players take turns zero-sum game. (Can be more than)
  2. Difficult to solve
  3. Focus on time efficiency

Formal

S0 initial state
Player (s) who act
Action (s) state legal move under s collection
Result (s, a) transition model
Terminal-test (s) to terminate the test, the game is finished
Utility (s, p) utility function

Game Tree

Tic-Tac-Toe game, the state of the node, the edge is moving. MAX and MIN chess turns, the number of leaf nodes is the utility value MAX is terminated in this state, the higher the value the better the MAX, MIN more unfavorable.

Second, the optimization of the decision-making game

Minimax algorithm

thought

Recursive algorithm has been advanced to a top-down tree leaf node, and then with a recursive search tree by the minimax value return.

In the final state node, the node returns utility value;

When the turn MAX, the node returns the maximum utility value of child nodes;

When the turn MIN, the node returns the minimum value of the utility value of the child node.

Fake code

action MINIMAX_DECISION(state){
    v=MAX_VALUE(state);
    return the action in SUCCESSORS(state) with value v;
}
value MAX_VALUE(state){
    if TERMINAL_TEST(state) then return UTILITY(state);
    v=-∞;
    foreach child of node
        v=MAX(v,MIN_VALUE(s));
    return v;
}
value MIN_VALUE(state){
    if TERMINAL_TEST(state) then return UTILITY(state);
    v=+∞;
    foreach child of node
        v=MIN(v,MAX_VALUE(s));
    return v;
}

performance

Completeness

Not necessarily comprehensive, complete in a finite state space and to avoid overlap.

Optimality

Optimal.

Time complexity
\ [O (b ^ m) \]
spatial complexity
\ [generated once all subsequent: O (bm) \]

\ [Generated each time a successor: O (m) \]

The maximum depth of the tree is m, each node has a valid line moves to b.

Multiplayer Game

To be replaced with a single value vector, the state vector represents the starting value of the utility obtained from each angle.

Union Alliance case and destruction may occur.

α-β pruning

thought

Cut the branch can not influence those decisions.

MAX best choice so far found on α = path;

β = MIN choice found so far on the path;

搜索中不断更新α与β的值,当某结点的值比当前的α或β更差时剪裁此结点剩下的分支。

举例

特点

α-β剪枝的效率很大程度上依赖于检查后继状态的顺序。

\[ 最佳剪枝情况下可以将时间复杂度从极大极小算法的O(b^m)减少到O(b^{m/2} ); \]

\[ 采用随机顺序检查的总结点数大约是O(b^{3m/4})。 \]

三、不完美的实时决策

资源限制

搜索空间巨大的问题,通过启发式评估函数EVAL(s)将非终止结点转变为终止结点与截断测试代替终止测试来解决。

评估函数

定义准则

  1. 对于终止状态的排序应该和效用函数一致
  2. 计算时间不能太长
  3. 对于非终止状态应该和取胜几率相关

评估值计算

期望

评估函数的效率值可能被映射到多个终止状态,用终止状态的概率来表示当前状态的期望值。

Eg.

假设根据经验,当出现两个兵对一个兵的状态,72% 获胜(效用+1); 20% 输(效用0), 8% 平局(效用1/2)。
期望值为:0.721+0.20+0.08*(1/2)=0.76

线性加权评估

\[ Eval(s) = w_1f_1(s) + w_2f_2(s) + … + w_nf_n(s) \]

\[ w_i为权值,f_i为相应特征值 \]

Eg.
\[ 对国际象棋来说,f_i可能是棋盘上每种棋子的数目,w_i可能是每种棋子的价值 \]
PS

线性评估假定特征之间是独立的,然而实际中特征之间具有关联性,比如国际象棋在残局中2个象比单个象的价值要高出2倍。

特征与权值来自于规律,这些规律可能要通过机器学习技术来确定评估函数的权值。

截断搜索

思想

在α-β剪枝算法中,将Terminal-test 被替换程cutoff-test(state,depth),Utility被替换程eval(state)。

cutoff-test(state,depth)截断策略:

当大于固定深度时返回True;

根据游戏允许的时间来决定深度。

特点

评估函数的近似性会使截断搜索可能导致错误

评估函数只适应于静态棋局,即不会很快出现大摇摆的棋局。

难以消除地平线效应(对方招数导致我方严重损失并且理论上基本无法避免),固定深度搜索会相信这些延缓招数能阻止实际无法避免的困境。

【单步延伸策略可以用来避免地平线效应,发现并记住一种“明显好于其他招数”的招数,当搜索达到指定深度界限,若单步延伸合法,则考虑此招。由于单步延伸很少,所以不会增加太多开销】

前向剪枝

思想

无需考虑直接剪枝一些子结点。

属于柱搜索的一种。柱搜索:每一层只考虑最好的n步棋

特点

可能导致最佳的行棋被剪掉

Product算法

思想

首先浅层搜索计算结点的倒退值v,再根据经验来估计深度d上的值是否在(α,β)范围外。

特点

使用先验的统计信息在一定程度上保护最佳行棋不被剪枝掉

搜索与查表

开局时的行棋大多依赖于人类的专业知识;

接近尾声的棋局可能性有限;

在开局和尾声阶段可以通过查表的方式来进行行棋。

四、随机博弈

思想

局面没有明确的极大极小值,只能计算棋局的期望值:机会结点所有可能结果的平均值。

将确定性博弈中的极小极大值一般化为包含机会结点的博弈的期望极大极小值。

举例

评估函数

评估函数应该与棋局获胜的概率成线性变换

时间复杂度
\[ O(b^mn^m) \]

五、部分可观察的博弈

军旗

棋子可以移动但对方看不见棋子是什么

使用信念状态

牌类

随机部分可观察

需要概率推算来制定决策

欢迎补充与指正,感谢点赞o( ̄▽ ̄)d

Guess you like

Origin www.cnblogs.com/Gru-blog/p/12099119.html