CSC 384 Introduction to Artificial Intelligence (Jan - Apr 2023)

Assignment 2: Solving Checkers Endgames using Search

 

Overview

In this assignment, you will implement search algorithms to solve several Checkers endgame puzzles, where a winning solution can always be found, given a strong enough AI.

The history of Checkers AI is a great story and a Canadian one! Check out the following article for the full tale: How Checkers Was Solved.

Game Rules

Checkers is a two-player board game played on an eight by eight chess board. One player's pieces are black, and the other player's pieces are red. The players take turns moving pieces on the board. The red player moves first.

We recommend that you start by playing some games of checkers to understand the game better. You can player checkers at this link

Three Images of Checkers Board

We will be coding the version of Checkers called Standard English Draughts. You can find the full rules at the link and also below.

 

Your Tasks

You will implement a program that can solve a Checkers endgame puzzle using alpha-beta pruning and additional techniques of your choosing. 

 

Running Your Program

You will submit a file named checkers.py, which contains your program that uses alpha-beta pruning and other techniques to solve a Checkers endgame puzzle.

Your program must use python3 and run on the teach.cs server (where we run our auto-testing script).

We will test your program using several Checkers endgame puzzles. For each puzzle, we will run the following command. 

    python3 checkers.py --inputfile <input file> --outputfile <output file>

Each command specifies one plain-text input file and one plain-text output file.

For example, if we run the following command for an input file puzzle1.txt

    python3 checkers.py --inputfile puzzle1.txt --outputfile puzzle1_sol.txt

The solution to puzzle1.txt will be in puzzle1_sol.txt.

 

Input and Output Formats

We will represent each state in the following format.

Here is an example of a state.

........
....b...
.......R
..b.b...
...b...r
........
...r....
....B...

Each input file contains one state. Your program controls the red pieces, and it is your turn to make a move.

Each output file contains the sequence of states until the end of the game. The first state is the same as the state in the input file. The last state is a state denoting the end of the game. There is one empty line between any two consecutive states.

Here are examples of an input file and an output file

 

Solving the Puzzles

Your program controls both players. Both players use alpha-beta pruning with the same depth limit to determine their best move at their turn.

The game proceeds as follows.

At each turn, perform alpha-beta pruning.

Depth Limit:

 

Testing Your Program

We will test your program on multiple puzzles of various difficulties. 

Our tests will verify that:

 

Your Program Design

Part of your assignment grade depends on the efficiency of your program. We encourage you to experiment with many techniques to optimize your program. In class, we mentioned two optimization techniques: node ordering and state caching.

Submit a one-page file named design.pdf. (We will grade the first page only if your file is longer than one page.) In this file, answer the three questions below.

 

Submission and Marking Scheme

You should submit two files on MarkUs.

We will test your program on several puzzles. For each puzzle, your program must terminate within 4 minutes. We strongly recommend testing your program on the teach.cs server to ensure that it terminates under the time limit.

We will provide two puzzles to you on MarkUs. Please use these to test the correctness and efficiency of your program.

The mark breakdown is as follows:

Marking Scheme
Component Percentage
Solution correctness 30%
Program efficiency 60%
Descriptions of your program design 10%

The marking scheme for correctness is below.

Correctness Marking Scheme
Criteria Percentage Earned (up to 30%)
Your solution is valid but not optimal. 20%
Your solution is optimal. 30%

The time limit for each test case is 4 minutes. The marking scheme for program efficiency is below. 

Program Efficiency Marking Scheme
Runtime Criteria

Percentage Earned (up to 60%)

Your program terminates within 2 minutes. 60%
Your program terminates within 4 minutes. 30%
Your program does NOT terminate within 4 minutes. 0%

 

Suggestions

Here are some suggested steps to tackle this assignment. Good luck!

 

Write a few classes and functions to simulate a Checkers game.

 

Write a few functions to implement Alpha-Beta Pruning.

 

Implement additional optimizations to speed up your program execution.