## Revision 0151e42e8c9bbe310270ea6f4f906c3e0e980607 (click the page title to view the current version)

# Adversarial Search

## Changes from 0151e42e8c9bbe310270ea6f4f906c3e0e980607 to current

--- title: Adversarial Search categories: session --- # Reading R&N Chapter 6 + The fundamental concept is **two-player, zero-sum games** + The basic solution technique is **minimax search** + Minimax search grows exponentially + heuristic searches are important (Section 6.3) # Briefing + Video lecture [mp4](multiplayer.mp4)/[ogg](multiplayer.ogg) provides a few anchor points for the material. It does not replace the text book. ## Two-plaer, Zero Sum games # Briefing (Quiz) + **State-machine** - to-move: state $\to$ player - actions: state $\to$ {action} - result: state $\times$ action $\to$ state - utility: state $\times$ player $\to\mathbb{R}$ + Minimax algorithm: - maximises utility for the player currently to move - **Tree Search**: optimise utility bottom-up - **min nodes and max nodes** - exhaustive research + Caveats and variations - Branching factor - multi-player games - alliances and trust - co-operative games - $\alpha\beta$ pruning - heuristic searches - Type A and Type B: - move generation - move evaluation + **Monte Carlo** Tree Search - Monte Carlo $\sim$ Stochastic Simulation - Balance Exploitation and Exploration + More Caveats + Stochastic Games - **Chance Nodes** + Partially Observable Games - the percept sequence is no longer the opponent's move. + Limitations - Section 6.7 + Intractible + Approximations and Assumptions + Individual moves - no sight of the bigger picture + What information has to be defined for each state in a minmax tree? + What information is specific for minmax trees? + What is the difference between minmax trees and and/or trees? + How can we exploit the adversariality of minmax trees compared to and/or trees? + What does it mean that Minmax search grows exponentially? + Is it possible to avoid exponential growth? + Name at least two approaches to reduce the run time. + What is the core idea in $\alpha$/$beta$-pruning? + What are the benefits of heuristic $\alpha$/$beta$-pruning compared to regular $\alpha$/$beta$-pruning? + What are the disadvantages of heuristic $\alpha$/$beta$-pruning compared to regular $\alpha$/$beta$-pruning? + What is the difference between Type A and Type B strategies? + What does the area actually searched (expanded) look like after respectively a Type A and a Type B search? + What is the main idea in a Monte Carlo Search? See also [Notes on Adversarial Search]() (brief bullet points used 2023) # Exercise ## Tic Tac Toe + [Code from github](https://github.com/hgeorgsch/pai-exercises/tree/main/TicTacToe) I was not able to find suitable exercises on CodinGame, so instead, I have provided a simulator for you. You should 1. Clone the git repo, `git clone https://github.com/hgeorgsch/pai-exercises.git` 2. Change to the `TicTacToe` subdirectory 3. Modify the template to implement your intelligent agent. You should use the minimax algorithm as described for two-player, zero sum games. 4. Play the game, using the test scripts: `python3 ttt.py` 5. Consult the README file for details. This assumes that you have git and python3 installed. ## Discussion From [R&N Exercises](https://aimacode.github.io/aima-exercises/game-playing-exercises/) + Exercise 1 + Exercise 3 ## Monte Carlo Tree Search + [Can you save the forest - Episode 1](https://www.codingame.com/training/medium/can-you-save-the-forest---episode-1) # Debrief All the algorithms we are studied are based on (discrete) **state machine models** and **tree search algorithms** in the graph defined by the states and transitions in the state machines. It is crucial that we understand the basic structure of these models and algorithms well, so that we can adapt them to the different special cases we encounter. All the algorithms we have studied are based on (discrete) **state machine models** and **tree search algorithms** in the graph defined by the states and transitions in the state machines. It is crucial that we understand the basic structure of these models and algorithms well, so that we can adapt them to the different special cases we encounter. + exhaustive searches in small state spaces - BFS - DFS + non-deterministic environments lead to random transitions + modelled by and-or trees + partial observation leads to belief states + in offline search we can jump to arbitrary nodes to restart the search + in online searches we need to backtrack by actual actions in the environment + two-player games lead to adversarial transitions + Minimax algorithm considers both own moves (max) and adversarial moves (min) + Why is adversarial search radically different from search in probabilistic games? + Pruning may be essential to speed up the algorithm + Dijkstra prunes subtrees which are known to give longer paths than the best one known + alpha-beta pruning applies to minimax search + Heuristics are estimates of the value/cost of a node. This allows + Greedu algorithms and best first searches + Heuristic pruning, discarding subtrees which look bad, but with no guarantee