210 likes | 334 Vues
This article explores strategies for improving gameplay in Tic-Tac-Toe through advanced algorithms like Minimax and Alpha-Beta Pruning. We delve into logical inference to identify optimal moves, categorizing good strategies such as blocking, forking, and identifying winning conditions. The use of representations for board positions and efficient move calculations is discussed, alongside the fundamentals of adversarial search. The piece also addresses challenges like non-quiescent positions and horizon effects, and suggests methods to evaluate choices in gameplay.
E N D
Tic-Tac-Toe • Can do minimax • And alpha-beta pruning • And improved representation • Can we use logical inference? ¬
Logical approach • X(n), O(n) represent board position. • O(1), X(5), O(6), X(9) • X(n) O(n) full(n) • ¬ full(n) empty(n)
Some basic facts • ol(1,2,3), ol(4,5,6), ol(7,8,9) • ol(1,4,7), ol(2,5,8), ol(3,6,9) • ol(1,5,9), ol(3,5,7) • ol(a,b,c) line(a,b,c), ol(a,b,c) line(a,c,b), etc. for the permutations of a,b,c. • Hmm…permutations bad…
How to move • empty(a) goodMove(a) move(a)
What’s a good move? • Winning is good. • X(a) X(b) line(a,b,c) win(c) • win(n) goodMove(n)
What’s a good move? • Blocking a win is good. • O(a) O(b) line(a,b,c) block:win(c) • block:win(n) goodMove(n)
What’s a good move? • Forking/splitting is good • X(b) X(c) b≠c line(a,b,d) line(a,c,e) empty(d) empty(d) fork/split(c) • fork/split(n) goodMove(n)
What’s a good move? • Blocking forking/splitting is good • O(b) O(c) b≠c line(a,b,d) line(a,c,e) empty(d) empty(d) block:fork/split(c) • block:fork/split(n) goodMove(n)
What’s a good move? • Just moving somewhere is good (base facts). • goodMove(1), goodMove(2), goodMove(3), etc. • Remember: empty(a) goodMove(a) move(a)
Questions… • How to order the inference application? • How to order the goodMove rule application? • How does this differ from minimax?
Answers • Ordering inference application • Write Horn clauses, use Prolog application rules. • X(a) O(a) full(a) • full(A) :- X(A). • full(A) :- Y(A). • Relatively simple backtracking (although lots of speedup tricks are used). • full(3)? If X(3), yes; else if Y(3), yes. • full(P)? If X(P). X(P)? X(0), … etc.
Answers • Ordering good Rule application • Order doesn’t matter here: • full(A) :- X(A). • full(A) :- Y(A). • But does matter here: • move(A) :- empty(A), goodMove(A). • goodMove(1). • goodMove(A) :- win(A). • Just put them in the order you wish … but this may be hard to do.
Relation to MiniMax? • In some ways, not much. • Can Utility measures give us information about good rule ordering?
More on adversarial search • Alpha-beta pruning: good! • Recognizing repeated states: good! (for speed and space) • Recognizing equivalent states: good! (for speed and space)
Can’t go very deep • Still, Deep Blue reached 14 plies routinely • Other heuristics helped
What to do? • Evaluate intermediate positions if you can’t play the end-game out.
Typical problems • Non-quiescent positions • Horizon effect • Lack of information
Games of chance • Expected value of a choice. • Prob(choice)* Value(choice). • Extend Minimax to use expected value. • But … (averaging over claivorance) • A | [B | C] • B >> A, B >> C
When weak methods don’t work • Use strong ones • Strong methods might apply across domains • Might want to do planning.
Othe games? • What about, say, non-adversarial games (current AI in game research)? • Might want to do planning.