WK8: Search Algorithms and Game Playing

Welcome to Week 8
Search Algorithms and 
Game Playing
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk

1 / 15
volgende
Slide 1: Tekstslide
Artificial Intelligence ProgrammingHigher Education (degree)

In deze les zitten 15 slides, met tekstslides.

Onderdelen in deze les

Welcome to Week 8
Search Algorithms and 
Game Playing
Module Lecturer: Dr Raghav Kovvuri
Email: raghav.kovvuri@ieg.ac.uk

Slide 1 - Tekstslide

Deze slide heeft geen instructies

 Introduction
Scope of Today's Session
  1. Introduction to Search Algorithms
  2. Uninformed vs Informed Search
  3. Game Theory and Game Playing
  4. Minimax Algorithm and Alpha-Beta Pruning
  5. Practical Implementations
Why Search Algorithms?
  • Foundation of problem-solving in AI
  • Essential for pathfinding, optimization
  • Core component of game playing AI

Slide 2 - Tekstslide

Deze slide heeft geen instructies

Understanding Search Algorithms
Core Components







1. State Space:
  • All possible states in the problem
  • Initial state and goal state
  • Valid transitions between states

2. Search Tree/Graph:
  • Nodes represent states
  • Edges represent actions
  • Path represents solution



Real-world Analogy:
GPS Navigation System: All possible locations (States), Available roads (Actions), Reaching destination (Goal)

Slide 3 - Tekstslide

Deze slide heeft geen instructies

Types of Search Strategies (1)
Uninformed Search (Blind Search)

1. Breadth-First Search (BFS)
  • Layer by layer exploration
  • Complete and optimal
  • High memory requirements


BFS Visualisation

Slide 4 - Tekstslide

Deze slide heeft geen instructies

Types of Search Strategies (2)
DFS Visualisation
Depth-First Search (DFS)
  • Explores deep paths first
  • Memory efficient
  • May not find optimal solution
Uninformed Search (Blind Search)

Slide 5 - Tekstslide

Deze slide heeft geen instructies

Types of Search Strategies (3)
DFS is a common way that many people naturally approach solving problems like mazes

Slide 6 - Tekstslide

Deze slide heeft geen instructies

      Download BFS_DFS.py
Exercise & Discussion
BFS vs DFS (See Discussion section in Canvas)
  1. What are the key differences between BFS and DFS in terms of their traversal methods and order of visiting nodes?
  2. How do the time complexities of BFS and DFS compare? In what types of graphs (dense vs. sparse) does each algorithm perform better?
  3. Why does BFS generally require more memory than DFS? Discuss the space complexities of both algorithms.
  4. In which scenarios would BFS be more advantageous than DFS, and vice versa? Provide real-world examples for each
Submit your findings to Canvas

Slide 7 - Tekstslide

Deze slide heeft geen instructies

Informed Search: Informed Search uses additional information (often a heuristic) to guide the search process more effectively toward a goal. Unlike BFS and DFS, which explore the search space blindly, informed search algorithms prioritize paths that seem more promising.
  • Best-First Search
  • A* Search (Preview of next week)
Types of Search Strategies (2)

Slide 8 - Tekstslide

Deze slide heeft geen instructies

Game Theory Concepts (1)
Game Theory is a branch of mathematics which core idea is to analyse the potential strategies of all participants (or "players") in a scenario where the outcome depends on the choices made by each player. The goal is often to find an "optimal" strategy that maximizes a player’s payoff while considering the actions of others.

Slide 9 - Tekstslide

Deze slide heeft geen instructies

Game Theory Concepts (2)
Key concepts:
Players: The decision-makers in the game.
Strategies: The choices or plans of action available to each player.
Payoffs: The outcomes or rewards received based on chosen strategies.
Equilibrium: A state where no player can improve their payoff by unilaterally changing their strategy

Slide 10 - Tekstslide

Deze slide heeft geen instructies

Minimax Algorithm is a decision rule commonly used in game theory and artificial intelligence, particularly in zero-sum games like chess or tic-tac-toe, where one player’s gain is the other’s loss. It’s designed to minimize the possible loss in a worst-case scenario. 
The Minimax Algorithm (1)
             For example, in a game like tic-tac-toe, the minimax algorithm will calculate the outcome of every possible move and counter-move, selecting the move that ensures the best result for the player following the optimal strategy.

Slide 11 - Tekstslide

Two Players: In a typical setup, you have a maximizing player (seeking the highest possible score) and a minimizing player (seeking to lower the maximizing player’s score).
Decision Tree: The game can be represented as a tree of possible moves, with each node representing a game state and each edge representing a move by either player.
Recursive Evaluation: The algorithm evaluates the game tree from the bottom (leaf nodes) to the top (root node), simulating all possible moves by both players. It assumes the opponent will play optimally, so each player tries to "minimize" the maximum advantage of their opponent (hence the term "minimax").
Outcome: The optimal move for the maximizing player is the one that leads to the maximum score, while the minimizing player tries to force the worst possible score for the maximizing player.
The Minimax Algorithm (2)
Draw the Game Tree: Show all possible moves up to the end states.
Score the End States: Assign scores to each end state (e.g., +1 for a win, -1 for a loss, 0 for a draw).
Backtrack Scores: For each intermediate state:
  • If it’s the Maximizing Player’s turn, pick the move with the highest score.
  • If it’s the Minimizing Player’s turn, pick the move with the lowest score.
Select Best Move at Root: Choose the move from the root that leads to the optimal outcome for the Maximizing Player.

Slide 12 - Tekstslide

Deze slide heeft geen instructies

Alpha-Beta Pruning (See Discussion section in Canvas)
How does Alpha-Beta Pruning improve the efficiency of the Minimax algorithm in game tree search? Discuss the conditions under which Alpha-Beta Pruning can achieve the best performance. Can you provide examples of real-world applications where Alpha-Beta Pruning is particularly beneficial?
Exercise & Discussion
Submit your findings to Canvas
       Download Tic_Tac_Toe.py from Canvas

Slide 13 - Tekstslide

Deze slide heeft geen instructies

Conclusion
Search algorithms and game playing form a crucial foundation in AI programming. Through BFS and DFS, we understand how AI can systematically explore possibilities to find solutions. The Minimax algorithm demonstrates how AI can make strategic decisions in adversarial scenarios.
Key takeaways:
  • BFS is optimal for unweighted shortest paths
  • DFS can be more memory-efficient
  • Minimax enables optimal decision-making in perfect information games
  • These concepts form the basis for more advanced search algorithms


Next Week: We'll explore pathfinding algorithms, building on these search concepts.

Slide 14 - Tekstslide

Deze slide heeft geen instructies

Slide 15 - Tekstslide

Deze slide heeft geen instructies