proc depth-bounded-minimax(n: node)
begin
L ←[n];
while n ≠car(L) ∨<nに値が対応付けられていない> do
begin
x ←car(L);
if <xに値vx が対応付けられている>;
then begin
x ←pop(L);
p ←<xの親>;
vp ← <現在pに対応付けられている値>;
case <ノードpのタイプ> of
最小化ノード: vp ← min(vp,
vx);
最大化ノード: vp ← max(vp, vx);
end
end
else if <xが終端ノードである>∨<深さ限界に達した>
else
begin
case <xのタイプ> of
最大化ノード: vx ← -∞;
最小化ノード: vx ← +∞;
end
<xの子供をLの先頭に追加する>;
end
end
end
|