Alpha Beta Pruning in Adversarial Search

Alpha Beta Pruning in Adversarial Search

Minimax Implementation

def max-value(state):
	initialize v = -∞
	for each successor of state:
		v = max(v, min-value(successor))
	return v

def min-value(state):
	initialize v = +∞
	for each successor of state:
		v = min(v, max-value(successor))
	return v

V ( s ) = m a x ( V ( s ′ ) ) s ′ ∈ s u c c e s s o r ( s ) V(s) = max(V(s')) s' \in successor(s) V(s)=max(V(s))ssuccessor(s)

V ( s ′ ) = m i n ( V ( s ) ) s ∈ s u c c e s s o r ( s ′ ) V(s') = min(V(s)) s \in successor(s') V(s)=min(V(s))ssuccessor(s)

Alpha Beta Pruning

General configuration (MIN version)
  We’re computing the MIN-VALUE at some node n
  We’re looping over n’s children
  n’s estimate of the childrens’ min is dropping
  Who cares about n’s value? MAX
  Let α \alpha α be the best value that MAX can get at any choice point along the current path from the root
  If n becomes worse than α \alpha α, MAX will avoid it, so we can stop considering n’s other children (it’s already bad enough that it won’t be played)

MAX version is symmetric

Examples

Example one

To start with, we know nothing about the bounds, so we set α = − ∞ , β = ∞ \alpha = - \infty, \beta = \infty α=,β=.

Step one

Then we passing along the bounds to the child, child’s child…

Step two

Step three

Now we reach at the level: depth of 4. We run our evaluation functions here.

An evaluation function is like:
Ideal function: returns the actual minimax value of the position
In practice: typically weighted linear sum of features: E v a l ( s ) = w 1 f 1 ( s ) + ⋅ ⋅ ⋅ + w n f n ( s ) Eval(s) = w_1f_1(s) + \cdot\cdot\cdot + w_nf_n(s) Eval(s)=w1f1(s)++wnfn(s).

We get value 3, since this is a min node, we now know the minmax value must be less than or equal to 3, thus, we set β = 3 \beta = 3 β=3.

Step four

Next child in depth 4 is value 17, while 17 > 3, we ignore this child.

All children handled, we return to depth 3. we have β = 3 \beta = 3 β=3 here, so we can set α = 3 \alpha = 3 α=3 at the depth 2 node.

Step five

We pass along the bounds of depth2 to next child of depth3.

Step six

Step seven

At this moment, we get α = 3   a n d   β = 2 , α > β \alpha = 3 \space and \space \beta = 2, \alpha > \beta α=3 and β=2,α>β.
If these values are to change, children values would be greater than 3 and less than 2, which is impossible. We can prune any children and return.

We do these steps recursively, we will reach this:

Step eight

Some pictures and ideas comes from h t t p s : / / w w w . c s . u c l a . e d u / https://www.cs.ucla.edu/ https://www.cs.ucla.edu/.

Two Quiz

notice: I do not have answers.

Quiz one

Quiz two

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值