Reversi (Othello)
For ths assignment, you will be creating an agent that plays the game
Reversi (also known by the trademark Othello). Reversi is a
two-person, full information game. Rules, and some basic
strategy, can be found
here.
Your Assignment
For this assignment, you will create a file named <username>.py,
(where <username> is your username) which contains the following
2 python functions:
- nextMove(board, color, time)
where
- board is a representation of the board:
The board will be represented as a list of list of strings (that is, a
2D array of strings). Each string will be "B" for black, "W" for
white, or "." for an empty square.
- color is either the string "B" or the string "W", representing the color to play
- time is the time left on your tournament clock (in seconds).
- nextMoveR(board, color, time)
Which is identical to doMove, except it plays the Reversed
game (Reversed Reversi) -- when the object is to end with as
few pieces of your color as possible
Your nextMove (and nextMoveR) should return either a tuple representing the position on the
board to move, or the string "pass". (That is, if you return
(3,4), you mean to set board[3][4] = your color). Note that a pass is
only valid if there are no other moves to be made.
Your nextMove should do a minmax search, with alpha-beta pruning.
You should spend some time on a good evaluation function.
Singlular extensions and quiescent search may also be a good idea, but
are not required. Note that either making an illegal move, or
running out of time, will lose the match.
Provided Files
The following files are provided to help you get started
- gameplay.py Plays two agents against
each other. From the command line, this function is invoked with:
% python gameplay.py [-t<timelimit>] [-v] [-r] player1 player2
Where player1.py and player2.py are python files that contain a nextMove
and nextMoveR. The flags -v stands for verbose output (display the
board after every turn), and -r stands for "reversed" (use nextMoveR
rather than nextMove).
- randomPlay.py Sample agent that
makes a random legal move
- simpleGreedy.py Sampe agent that uses a brain-dead evaluation function, with no search
For example, you could have two random players play against each other with:
% python gameplay.py randomPlay randomPlay
If you wanted to play simpleGreedy against randomPlay (with
simpleGreedy going first), seeing all the moves, with a clock of 150
seconds:
% python gameplay.py -t150 -v simpleGreedy randomPlay
Important Notes
- All of your code must be contained within a single .py file,
that must be named <username>.py. For instace, if I was
turning in a n assignemnt, I would name it 'galles.py'
- Your code must be in subversion.
- Your functions must be named nextMove and nextMoveR, each of
which takes 3 parameters
- Your function must return a tuple, or the string "pass" (all lowercase)
Grading
This assignement is worth 100 points
- Correct min/max: 30 points
- Correct alpha-beta pruning 30 points
- Consistently beats a random player: 20 points
- Consistently beats my (very simple, not very smart) agent: 20 points
Contest
I will run all of your programs against each other, playing both black
and white, with a time limit of 320 seconds. The overall winner will
recieve an Amazon gift certificate. Places 1, 2, and 3 will receive
homework extra credit of 30pts, 20pts, and 10pts.