Homework #2: Game Playing
Specification Due: October 10th
Full Program Due: October 19th, 2006
Programs and specifications are due at the beginning of class on the due date.
You may work in teams of two on this assignment if you like. If you work in a team of two, you must allow for four person play.
For this assignment you are to write a program that can play Pente. You can make the following assumptions.
1. You are playing against one other opponent
(if you are doing the assignment alone) or an option for two or four
players if you working as part of a pair.
2. Your opponent can be either a human or a computer
How to play Pente: You are given a Pente board consisting of
a grid of 19X19 lines, plus two sets of stones. You
can assume an endless supply of stones. The first player (chosen by
chance) begins the game by playing one stone on the center
point. Thereafter, the players take turns playing their stones, one at
a time, on any empty intersection. There is one restriction: on the
second turn, the first player's move must not be within 2 spaces of the piece
on the center.
The stones are played on the
intersections of the lines (including the edge of the board), rather
than in the squares. Once played, a stone cannot be moved again
(except when removed by a capture as explained below).
The game is won by the first player to play five in a row or to
capture 5 pairs from the opponent.
When four players play, there are four colors, one per player. The
players split up into two teams. Team members sit opposite each
other. The first player moves on the center point. Thereafter the
players take turns, in a clockwise direction, placing their stones on
the intersectsions of the lines as in basic Pente. Each player
controls a different color of stones, and cooperates with his or her
partner for a team win. If you working in a pair, you need to
implement both two player and four player games. You can start by
implementing the four player game without teams and then add in
teams (i.e., it would be easier to start thinking about it without teams).
The full set of rules are provided at the two websites below. The
first has a little better explanation, but is lacking the restrictions
on the first player. The second states those restrictions.
Strategy. There is some strategy to playing Pente. Two of the web sites below
have more information on strategy, but at the basic level keep in mind
the following tips:
The best strategy for winning at Pente is to try to seize the
offensive. The person who is on the offensive is able to exercise more
control over the game's direction, and therefore over its final
outcome. Basically one gets on the offensive by making stronger moves
than one's opponent, which usually means having more stones in a row
so that he or she has to block your rows and not vice versa.
You will find that "threes" are the basic building blocks of threats
in Pente and come in a variety of shapes. Use them to gain the
initiative by quickly developing a series of intersecting threes and
fours and extending them in all directions. Keep moving to give
oneself as many options for further play as possible, placing the
stones so that they build upone each other, until an unstoppable
"double threat" is achieved.
When looking for good moves consider those that seem like they might
come naturally. Moves that give the position balance or symmetry often
work very well, as do moves that are visually striking or
appealing. Often the point where the opponent would like to play next
is also the best place for one's own stone.
Websites:
Rules of Pente and links to strategies, but without restrictions on first player
Rules of Pente, with restrictions on first player.
Lots of
information on Pente, (you
can download a demo version of the game. Source code is
available here but you will not do well if you copy in any way.)
Implementation: You are to implement a minimax search using alpha-beta
pruning.
You should set up your program so that search depth can be a user provided
parameter and you can run your program with different levels of
lookahead.
You should implement an evaluation function that estimates how good a
particular game state is. You should consider strategies, such as the
ones given on the web sites, when implementing your
evaluation function. You will be graded in part on the creativity you show in implementing your evaluation function. In your program, you will need to keep track of
the state space, which should include the layout of the board and the
number of pairs that each player has captured. You will also need to
keep track of stones in a row; when you make a move that results in 5
stones in a row or 5 captured pairs, your program should declare that
you
are the
winner. Finally, if you make an illegal move, then you lose the game.
In order to limit your search space, at each turn, consider the
moves that are within 5 spaces in any direction of the pieces on the
board. You should not consider every possible space on the board.
Specifications: In order to ensure that you don't wait until
the last week to begin writing your program (in which case you will
most certainly not finish in time), you must turn in a specification
for your program by Oct. 10th. This should include: 1. the algorithm for alpha beta cut-offs, 2. a
description of the evaluation function that you plan to use (which
should include at least three features) and an algorithm that
computes the values for each feature, and 3. the algorithm for your
move generator. In addition, you should provide two paragraphs of text
that describe your approach. All algorithms should be provided in
pseudo code. The specification that you provide will count for 15% of
your grade.
What to turn in: For this assignment, you will use the online
submission to turn in the code and a readme file. All code should be
well documented. You will be graded in part based on this
documentation.
You will bring hard
copy of the readme file to class. You do not need to turn in hardcopy
of your code. The readme file should include: 1. A description of your
approach and any special points that you think we should know about,
2. A short paragraph explaining how you did each of the following
requirements and the name of the class that implements it in your
program: minimax search, alpha-beta pruning, move generator,
evaluation function, score computation.
If you are working in a pair, your readme file should describe what
each person of the team did and you should clearly identify who did
each piece of code. You can also describe parts that you did jointly.
You will be provided with a module which will actually perform the move that your program decides to make and update the state space.
There will be a tournament following the due date which is optional. Everyone entering the tournament will receive 10 points of extra credit and there will be a series of extra credits for teams that win at each round.