Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP4031Artificial Intelligence for Games and Puzzles1 The Shape of a Game Tree Fragment Standard  -  is an algorithm which performs the same computation.

Similar presentations


Presentation on theme: "COMP4031Artificial Intelligence for Games and Puzzles1 The Shape of a Game Tree Fragment Standard  -  is an algorithm which performs the same computation."— Presentation transcript:

1 COMP4031Artificial Intelligence for Games and Puzzles1 The Shape of a Game Tree Fragment Standard  -  is an algorithm which performs the same computation as minimax for a given tree - avoiding generating useless parts of that tree. Quiescence Search can be seen as a method for defining the shape of a tree by means other than truncating it at a fixed depth. Quiescence Search can be used as an evaluation function at the leaves of an  -  search (or any other for that matter, even itself: Second Order Quiescence). It allows further search to be used as if it were a static evaluation function. Null-Move Quiescence Search generates at least a fringe of null-moves one ply beyond the normal fixed depth of the tree (though null moves are very cheap)

2 COMP4031Artificial Intelligence for Games and Puzzles2 Null Move Quiescence as an Evaluation Function NMQuiesce (real lower, real upper) /* initially - , +  */ {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

3 COMP4031Artificial Intelligence for Games and Puzzles3 Animation of Null-Move Quiescence Search Nodes in search tree generally have six attributes: After consideration of a node is complete, collapse it to: Integers, not reals, will be used for simplicity. Whose MoveLower boundUpper bound Value ProducedBest ValueTemporary Value Whose Move Value Produced

4 COMP4031Artificial Intelligence for Games and Puzzles4 What is the value of the position? NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score} W -- ++

5 COMP4031Artificial Intelligence for Games and Puzzles5 Generate null move W -- ++ B -- ++  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

6 COMP4031Artificial Intelligence for Games and Puzzles6 Generate null move and evaluate it W -- ++ B -- ++ +0  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

7 COMP4031Artificial Intelligence for Games and Puzzles7 Use that evaluation W -- ++ -0 B +0  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

8 COMP4031Artificial Intelligence for Games and Puzzles8 Since 0 < + , generate 1st real move W -- ++ -0 B +0  B -- 0 K-h3 NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

9 COMP4031Artificial Intelligence for Games and Puzzles9 Start with null move W -- ++ -0 B +0  B -- 0 K-h3 W0 ++  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

10 COMP4031Artificial Intelligence for Games and Puzzles10 Statically evaluate W -- ++ -0 B +0  B -- 0 K-h3 W0 ++ 0  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

11 COMP4031Artificial Intelligence for Games and Puzzles11 Use that evaluation W -- ++ -0 B +0  B -- 0 0 K-h3 W 0  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

12 COMP4031Artificial Intelligence for Games and Puzzles12 Since “best 0” <= “upper 0”, W -- ++ -0 B +0  B -- 0 0 K-h3 W 0  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

13 COMP4031Artificial Intelligence for Games and Puzzles13 Since “best 0” <= “upper 0”, immediately return 0 W -- ++ -00 B +0  B 0 W 0  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

14 COMP4031Artificial Intelligence for Games and Puzzles14 0 = 0, and 0 < + , so generate next move available W -- ++ -00 B +0  B 0 W 0  B -- 0 NxP NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

15 COMP4031Artificial Intelligence for Games and Puzzles15 Obtain null-move evaluation W -- ++ -00 B +0  B 0 W 0  B -- 0 NxP W +1  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

16 COMP4031Artificial Intelligence for Games and Puzzles16 Since “upper 0” > “best -1”, try 1st move W -- ++ -00 B +0  B 0 W 0  B -- 0 NxP W +1  W0+1+1 K-g7 NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

17 COMP4031Artificial Intelligence for Games and Puzzles17 Obtain null-move evaluation W -- ++ -00 B +0  B 0 W 0  B -- 0 NxP W +1  W0+1+1 K-g7 B  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

18 COMP4031Artificial Intelligence for Games and Puzzles18 Now “best +1” >= “upper +1”, W -- ++ -00 B +0  B 0 W 0  B -- 0 NxP W +1  W0+1+1 K-g7 B  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

19 COMP4031Artificial Intelligence for Games and Puzzles19 Now “best +1” >= “upper +1”, so return value +1 W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W K-g7 B  NMQuiesce (real lower, real upper) {real Temp, Best; makenull(); Score:= - realevaluationfunction( - upper, - lower) unmakenull(); for every move M {if Score>=upper then Return Score; makemove(M); Temp:= - NMQuiesce( - upper, - best); unmakemove(); Score:=Max(Score,Temp)} Return Score}

20 COMP4031Artificial Intelligence for Games and Puzzles20 Try another move W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W B  W0+1 BxN

21 COMP4031Artificial Intelligence for Games and Puzzles21 Null move evaluation W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W B  W0+1 -2 BxN B +2 

22 COMP4031Artificial Intelligence for Games and Puzzles22 “best -2” < “upper +1”, so off again … W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W B  W0+1 -2 BxN B +2 

23 COMP4031Artificial Intelligence for Games and Puzzles23 Try a move W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W B  W0+1 -2 BxN B +2  B+2 K-h3

24 COMP4031Artificial Intelligence for Games and Puzzles24 Use null move evaluation, test, return W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W B  W0+1 -2 BxN B +2  B+2 K-h3 W -2

25 COMP4031Artificial Intelligence for Games and Puzzles25 Try another move W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W B  W0+1 -2 BxN B +2  B W -2 B +2 P-f4 W -2

26 COMP4031Artificial Intelligence for Games and Puzzles26 Try all moves in turn W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W B  W0+1 -2 BxN B +2  B W -2 B +2 K-g1 W -2 B +2 W -2

27 COMP4031Artificial Intelligence for Games and Puzzles27 Eventually settling on a value W -- ++ -00 B +0  B 0 W 0  B -- 0 +1 NxP W +1  W B  W0+1 -2 BxN B +2  B W -2 B +2 K-g1 W -2 B +2 W -2

28 COMP4031Artificial Intelligence for Games and Puzzles28.. Which is returned W -- ++ -00 B +0  B 0 W 0  B -- 0 +2 NxP W +1  W B  W -2 BxN B +2  B W -2 B +2 K-g1 W -2 B +2 W -2

29 COMP4031Artificial Intelligence for Games and Puzzles29.. Which is returned, compared W -- ++ -00 B +0  B 0 W 0  B -- 0 +2 NxP W +1  W B  W -2 BxN B +2  B W -2 B +2 K-g1 W -2 B +2 W -2

30 COMP4031Artificial Intelligence for Games and Puzzles30.. Which is returned, compared, found to be better W -- ++ -00 B +0  B 0 W 0  B -- 0 +2 NxP W +1  W B  W -2 BxN B +2  B W -2 B +2 K-g1 W -2 B +2 W -2

31 COMP4031Artificial Intelligence for Games and Puzzles31 All other black moves are considered, (null not shown) W -- ++ -00 B +0  B 0 W 0  B -- 0 +2 NxP W +1  W B  W -2 B-a3 B +2  B W -2 B +2 W -2 B +2 W -2 W -- ++ 0

32 COMP4031Artificial Intelligence for Games and Puzzles32 Eventually determining a value W -- ++ -0-2 B +0  B 0 W 0  B +2 NxP W +1  W B  W -2 B-a3 B +2  B W -2 B +2 W -2 B +2 W -2 W

33 COMP4031Artificial Intelligence for Games and Puzzles33 Demonstrating that that capture is not good W -- ++ -0-2 B +0  B 0 W 0  B +2 W +1  W B  W -2 B +2  B W -2 B +2 W -2 B +2 W -2 W

34 COMP4031Artificial Intelligence for Games and Puzzles34 Other moves are considered (null again not shown) W -- ++ -00 B +0  B 0 W 0  B -- 0 +2 W +1  W B  W -2 B +2  B W -2 B +2 W -2 B +2 W -2 W B -- 0 00 N-c3

35 COMP4031Artificial Intelligence for Games and Puzzles35 Eventually determining a value for the initial position W -- ++ 0-00 B +0  B 0 W 0  B -- 0 +2 W +1  W B  W -2 B +2  B W -2 B +2 W -2 B +2 W -2 W B 0 N-c3

36 COMP4031Artificial Intelligence for Games and Puzzles36 Null-Move values as bounds The value determined for every node arises originally as the result of an evaluation of a null move. These evaluations - assuming the position is not zugzwang - are properly thought of as providing (lower) bounds on the value of a position. (Not to be confused with alpha and beta - achievable and hope - which are bounds on the range of values one is interested in exploring.) “The value of this position is at least N” is more reliable than “The value of this position is N” The value of the topmost node arises not from one evaluation providing one bound, but from two or more opposing evaluations providing touching bounds.

37 COMP4031Artificial Intelligence for Games and Puzzles37 Touching bounds The smallest possible tree for null-move quiescence: +4 -4 +4

38 COMP4031Artificial Intelligence for Games and Puzzles38 Quiescence as Evaluation The sort of evaluation performed by QUIESCE is to be performed at every leaf node of a MINIMAX (or AlphaBeta) search.

39 COMP4031Artificial Intelligence for Games and Puzzles39 Second Order Quiescence Since Quiescence Search can be regarded as an evaluation function, it can be used as such within another quiescence search: wherever the main quiescence search generates and evaluates a null move, that evaluation is performed using quiescence search with the real evaluation function.

40 COMP4031Artificial Intelligence for Games and Puzzles40 Evaluations that produce bounds on values Null moves may be regarded as producing a lower bound on a position’s value. A quiescence search that is terminated early - for example, by being restricted in terms of the depth of tree it may build or the number of nodes it may generate - may produce a “fat value” - a combination of A reliable lower bound (assuming no zugzwang) A reliable upper bound (assuming no zugzwang) Possibly, an unreliable value in between Fat values may also be produced by other means, for instance a pairing of a pessimistic evaluation function and an optimistic one. Some search algorithms, eg Berliner’s B* algorithm, work with value ranges rather than point values. More on B* another day …

41 COMP4031Artificial Intelligence for Games and Puzzles41 Bounds on values of interest to a search The AlphaBeta tree search algorithm uses its parameters  (achievable) and  (hope) to cut off search of parts of the game tree which cannot affect the minimaxed value ultimately found at the root. Once it is determined that a subtree’s value falls outside certain bounds, it can be abandoned. Conventionally, AlphaBeta is started off (at a root node) in an agnostic manner:  =-  and  =+  corresponds to having no idea what the value of the position is. Some interesting algorithms use an AlphaBeta search with different  and  : using a narrower search window in the expectation of getting more cutoffs. Aspiration Search NegaScout & PVS (Principal Variation Search) Scout MTD(f)


Download ppt "COMP4031Artificial Intelligence for Games and Puzzles1 The Shape of a Game Tree Fragment Standard  -  is an algorithm which performs the same computation."

Similar presentations


Ads by Google