Docsity

Game Playing as Search: Principles, Techniques, and Applications - Prof. Introduction to A, Summaries of Material Engineering

Partial preview of the text

Download Game Playing as Search: Principles, Techniques, and Applications - Prof. Introduction to A and more Summaries Material Engineering in PDF only on Docsity!

Set 4: Game-Playing

ICS 271 Fall 2016 Kalev Kask

Overview

  • Computer programs that play 2-player games
    • game-playing as search
    • with the complication of an opponent
  • General principles of game-playing and search
    • game tree
    • minimax principle; impractical, but theoretical basis for analysis
    • evaluation functions; cutting off search; replace terminal leaf utility fn with eval fn
    • alpha-beta-pruning
    • heuristic techniques
    • games with chance
  • Status of Game-Playing Systems
    • in chess, checkers, backgammon, Othello, etc, computers routinely defeat leading world players.
  • Motivation: multiagent competitive environments
    • think of “nature” as an opponent
    • economics, war-gaming, medical drug treatment

Search versus Games

  • Search – no adversary
    • Solution is a path from start to goal, or a series of actions from start to goal
    • Heuristics and search techniques can find optimal solution
    • Evaluation function: estimate of cost from start to goal through given node
    • Actions have cost
    • Examples: path planning, scheduling activities
  • Games – adversary
    • Solution is strategy
      • strategy specifies move for every possible opponent reply.
    • Time limits force an approximate solution
    • Evaluation function: evaluate “goodness” of game position
    • Board configurations have utility
    • Examples: chess, checkers, Othello, backgammon

Solving 2-player Games

  • Two players, fully observable environments, deterministic, turn-taking, zero-sum games of perfect information
  • Examples: e.g., chess, checkers, tic-tac-toe
  • Configuration of the board = unique arrangement of “pieces”
  • Statement of Game as a Search Problem:
    • States = board configurations
    • Operators = legal moves. The transition model
    • Initial State = current configuration
    • Goal = winning configuration
    • payoff function (utility) = gives numerical value of outcome of the game
  • Two players, MIN and MAX taking turns. MIN/MAX will use search tree to find next move
  • A working example: Grundy's game
    • Given a set of coins, a player takes a set and divides it into two unequal sets. The player who cannot do uneven split, looses.
    • What is a state? Moves? Goal?

Game Trees: Tic-tac-toe

How do we search this tree to find the optimal move?

The Minimax Algorithm

• Designed to find the optimal strategy or just best first move for MAX

– Optimal strategy is a solution tree

Brute-force:

– 1. Generate the whole game tree to leaves

– 2. Apply utility (payoff) function to leaves

– 3. Back-up values from leaves toward the root:

• a Max node computes the max of its child values

• a Min node computes the min of its child values

– 4. When value reaches the root: choose max value and the

corresponding move.

Minimax:

Search the game-tree in a DFS manner to find the value of the root.

Two-Ply Game Tree

Two-Ply Game Tree

Properties of minimax

• Complete?

– Yes (if tree is finite).

• Optimal?

– Yes (against an optimal opponent).

– Can it be beaten by an opponent playing sub-optimally?

• No. (Why not?)

• Time complexity?

– O(b

m

• Space complexity?

– O(bm) (depth-first search, generate all actions at once)

– O(m) (backtracking search, generate actions one at a time)

Game Tree Size

  • Tic-Tac-Toe
    • b ≈ 5 legal actions per state on average, total of 9 plies in game.
      • “ply” = one action by one player, “move” = two plies.
    • 5 9 = 1,953,
    • 9! = 362,880 (Computer goes first)
    • 8! = 40,320 (Computer goes second)  exact solution quite reasonable
  • Chess
    • b ≈ 35 (approximate average branching factor)
    • d ≈ 100 (depth of game tree for “typical” game)
    • b d ≈ 35 100 ≈ 10 154 nodes!!  exact solution completely infeasible
  • It is usually impossible to develop the whole search tree. Instead develop part of the tree up to some depth and evaluate leaves using an evaluation fn
  • Optimal strategy (solution tree) too large to store.

Applying MiniMax to tic-tac-toe

  • The static evaluation function heuristic

Backup Values

Feature-based evaluation functions

• Features of the state

• Features taken together define categories

(equivalence) classes

• Expected value for each equivalence class

– Too hard to compute

• Instead

– Evaluation function = weighted linear combination of feature

values