Skip to content

SimoneDeidier/ItoAI-ASSIGNMENTS-2024

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Introduction to Artificial Intelligence

Python License Status GitHub

A comprehensive collection of three assignments exploring fundamental Artificial Intelligence concepts including constraint satisfaction, game theory, and search algorithms.


πŸ“‹ Overview

This repository contains coursework from an Introduction to Artificial Intelligence course, implementing core AI algorithms and problem-solving techniques. The assignments progress from constraint-based problem solving to adversarial game playing with advanced search strategies.

Key Topics Covered

  • Constraint Satisfaction Problems (CSP)
  • Search Algorithms (AC-3, Backtracking, Minimax, Alpha-Beta Pruning)
  • Game Theory and Adversarial Search
  • Heuristic Methods and Optimization Techniques

πŸ“ Project Structure

IntroductionToArtificialIntelligence/
β”œβ”€β”€ assignment 1/
β”‚   β”œβ”€β”€ assignment 1.pdf                          # Problem statement
β”‚   └── assignment_1_deidier_esposito.pdf         # Solution report
β”‚
β”œβ”€β”€ assignment 2/
β”‚   β”œβ”€β”€ assignment 2.pdf                          # Problem statement
β”‚   β”œβ”€β”€ assignment_2_report_deidier_esposito.pdf  # Solution report
β”‚   β”œβ”€β”€ deliverables.zip                          # Submission package
β”‚   └── src/
β”‚       β”œβ”€β”€ csp.py                                # CSP implementation
β”‚       β”œβ”€β”€ map_coloring.py                       # Map coloring problem
β”‚       └── sudoku.py                             # Sudoku solver
β”‚       β”œβ”€β”€ sudoku_easy.txt
β”‚       β”œβ”€β”€ sudoku_medium.txt
β”‚       β”œβ”€β”€ sudoku_hard.txt
β”‚       └── sudoku_very_hard.txt
β”‚
β”œβ”€β”€ assignment 3/
β”‚   β”œβ”€β”€ assignment 3.pdf                          # Problem statement
β”‚   β”œβ”€β”€ assignment_3_deidier_esposito.pdf         # Solution report
β”‚   β”œβ”€β”€ deliverables.zip                          # Submission package
β”‚   β”œβ”€β”€ imgs/                                     # Documentation images
β”‚   └── src/
β”‚       β”œβ”€β”€ tic_tac_toe_minimax.py                # Tic Tac Toe with Minimax
β”‚       β”œβ”€β”€ tic_tac_toe_alpha_beta_pruning.py     # Tic Tac Toe with Alpha-Beta Pruning
β”‚       β”œβ”€β”€ tic_tac_toe_minimax_variant.py        # Alternative Minimax implementation
β”‚       β”œβ”€β”€ bucket_game.py                        # Game theory problem
β”‚       └── halving_game.py                       # Game theory problem
β”‚
β”œβ”€β”€ LICENSE
└── README.md (this file)

🎯 Assignment Details

Assignment 1: Foundational AI Concepts

Objective: Introduction to core AI problem-solving methodologies.


Assignment 2: Constraint Satisfaction Problems

Objective: Implement constraint satisfaction algorithms to solve complex combinatorial problems.

Key Implementations:

CSP Framework (csp.py)

  • AC-3 Algorithm: Arc Consistency checking for domain reduction
  • Backtracking Search: Complete search algorithm with constraint propagation
  • Binary constraint satisfaction with intelligent variable ordering

Applications:

  1. Map Coloring Problem (map_coloring.py)

    • Color Australian states using only 3 colors
    • No two adjacent states can have the same color
    • Demonstrates binary constraint satisfaction
  2. Sudoku Solver (sudoku.py)

    • Solves 9Γ—9 Sudoku puzzles with varying difficulty levels
    • Includes test cases: easy, medium, hard, and very hard
    • Uses AC-3 for initial constraint propagation and backtracking for complete solution

How to Run

cd assignment\ 2/src

# Solve map coloring problem
python3 map_coloring.py

# Solve Sudoku (adjust sudoku_easy.txt to sudoku_hard.txt as needed)
python3 sudoku.py

Assignment 3: Adversarial Search and Game Theory

Objective: Implement game-playing agents using minimax algorithms and explore game theory concepts.

Key Implementations:

Game Theory Problems:

  1. Tic Tac Toe with Minimax (tic_tac_toe_minimax.py)

    • Classic minimax algorithm implementation
    • Explores entire game tree to optimal depth
    • Two players, zero-sum game
    • Finds the best move without pruning
  2. Tic Tac Toe with Alpha-Beta Pruning (tic_tac_toe_alpha_beta_pruning.py)

    • Optimized minimax using alpha-beta pruning
    • Eliminates unnecessary branches from game tree exploration
    • Significant performance improvement over standard minimax
    • Same optimal play with reduced computation time
  3. Tic Tac Toe Minimax Variant (tic_tac_toe_minimax_variant.py)

    • Alternative implementation of minimax algorithm
    • Demonstrates different approaches to game tree evaluation
  4. Bucket Game (bucket_game.py)

    • Game theory application with strategic choices
    • Players choose between predefined bucket options or single numbers
    • Demonstrates utility-based decision making
    • Uses minimax for optimal play
  5. Halving Game (halving_game.py)

    • Two-player sequential number reduction game
    • Actions: decrement (βˆ’1) or halve (Γ·2)
    • Educational example of game tree search with limited branching

How to Run

cd assignment\ 3/src

# Tic Tac Toe with standard Minimax
python3 tic_tac_toe_minimax.py

# Tic Tac Toe with optimized Alpha-Beta Pruning
python3 tic_tac_toe_alpha_beta_pruning.py

# Tic Tac Toe Minimax variant
python3 tic_tac_toe_minimax_variant.py

# Bucket Game
python3 bucket_game.py

# Halving Game
python3 halving_game.py

πŸš€ Getting Started

Requirements

  • Python 3.9 or higher
  • No external dependencies required (uses only Python standard library)

Installation

# Clone the repository
git clone https://github.com/SimoneDeidier/IntroductionToArtificialIntelligence.git
cd IntroductionToArtificialIntelligence

# Navigate to any assignment
cd assignment\ 2/src
python3 map_coloring.py

πŸ“Š Algorithms Used

Search Strategies

Algorithm Assignment Purpose
AC-3 Assignment 2 Arc consistency constraint propagation
Backtracking Assignment 2 Complete search with constraint satisfaction
Minimax Assignment 3 Optimal move selection in adversarial games
Alpha-Beta Pruning Assignment 3 Optimized minimax game tree exploration

πŸ“„ Reports

Each assignment includes a comprehensive solution report documenting:

πŸ‘¨β€πŸ’» Authors

  • Simone Deidier
  • Davide Esposito