|
Comp202: Principles of Object-Oriented Programming II
Fall 2006 -- Project
#5: Games 4 Two
|
Introduction
This project is not about Tic-Tac-Toe nor Othello. It uses a 2-person
game design as a vehicle to learn BIGGER concepts in computing:
- Abstraction
- Design Process
- Fundamental Principles.
In this project, you will be given a big chunk of a 2-person board game framework
and asked to write a few of its components, plug them in and obtain a program
that can run Tic-Tac-Toe and Othello with different types of players, human
and/or computer, using a variety of strategies to compute the next move while
playing the games. See the on-line demo!!
(You are not allowed to reverse engineer the demo to do your project).
The given game framework abstracts and decouples the different components
in a game and specifies them in terms of interfaces with only pure abstract
behaviors. For example, the rules of a game is abstracted and encapsulated
in an interface called IBoardModel. ABoardModel
is a specific implementation of this interface using the state pattern.
Playing a particular board game is a matter of writing a concrete subclass of
ABoardModel and plug it into the framework.
Nothing in the framework is changed!
Pair Programming
You are allowed and strongly encouraged to work in teams of at most 2 people.
Resources
Othello Game rules:
From Pressman Games, the manufacturer
Web page of an Othello fanatic: http://www.maths.nott.ac.uk/othello/othello.html
You are given the following.
- The source code of most of the game framework:
P5M1Source.jar. You can extract all the files from this jar file by
enter the command:
- Among the source files is GameModel.java
which is the class that encapsulates:
- the rules of a game,
- the strategies to compute the next move, and
- the management of players.
An important piece of code in GameModel.java is stubbed out. You
will be required to complete it.
- The UML and javadoc that describes framework
design.
- The binary class files of the complete framework:
P5M2.jar. You are allowed to reverse engineer it to study the design,
but not to reverse engineer the code.
- The binary class file for the TicTacToe game
board: tttboard.jar. It contains the class files for TicTacToeBoard,
a class that you will be required to implement (i.e. write the code).
Your task for this project is to do the following.
- Fill out the stubs in the GameModel.java (in
the "model" package), i.e. instantiate the
IRequestor object.
The
upcoming lab (lab #11) will help you with this part.
- Implement the Tic-Tac-Toe board model by completing the provided skeleton
TicTacToeBoard.java.
- Implement a random move strategy that selects a move from the set of legal
(i.e.valid) moves only. Hint: take a look at RandomMoveStrategy.java
and the stubbed out RandomValidMove.java
file.
- Implement MinMax principle.
- Implement Alpha-Beta pruning strategy.
- Implement Depth-limited search strategy that works for any specified depth..
- GameModel.java has a method called getPlayers(). In this method, the
code to add players playing the strategies described in items 3, 4, 5 in the
above is commented out. These strategies must be written in such a way
that when this code fragment is uncommented, the whole GameModel.java will
compile and run properly.
- Be sure to document (in javadoc style) all the code you write.
Use the user ID of one of the team members as the package name for all of
the above strategies.
See the Hints on INextMoveStrategies
page!
Submission
Milestone 1 Requirements:
See Class Schedule for submission time and date
- Do steps 1, 2, 3 of the above task list.
- Zip up your entire
directory for milestone 1 and upload it as HW08, using the the assignment upload
web page.
RECOMMENDATION
Backup your entire
milestone 1 folder BEFORE commencing on milestone 2!
Milestone 2 Requirements:
See Class Schedule for submission time and date
- Do steps 4, 5, 6, 7 of the above task list.
- Zip up your entire
directory for milestone 1 and upload it as HW09, using the the assignment upload
web page.
No late submission will be accepted. The submission should contain the
following:
All submissions MUST contain the following:
- A plain text file called README
documenting what you have and/or have not done, describing
specific details that you feel we need to know when grading your work.
This README file alone is worth 5 points.
- Pledge of Honor: add
your pledge of honor to the README file.
- All the Java source code necessary to compile and execute your code.
Othello Tournament
During the week of the final, we will hold a tournament to select a new Othello
champion. Participation is totally optional.
P4M2.jar is the binary that will be used for the Othello tournament. To
run the code, enter the following command (on Owlnet Solaris machines).
java -classpath .:P5M2.jar:tttboard.jar controller.GameApp
In Windows, the command is
java -classpath .;P5M2.jar;tttboard.jar controller.GameApp
We will announce the tournament rules later. One key rule is for you
to use your user id as the package name for your best Othello next move strategy.
If you would like a reasonably challenging opponent
(though not a tournament-winning capable one), download the following jar file:
comp202prof.jar. Add this
jar file to the "Extra Classpaths" in your DrJava Preferences/Resource
Locations. To load the strategy, load in the following class name after
Othello starts up: comp202prof.SBW_DXN_strategy1
Tips and Traps
In no particular order...
-
Be sure to properly initialize _val in MinAcc and MaxAcc. What do you want
to happen the very first time that updateBest() is called?
-
When creating an (x,y) Point from a (row, col), which is the row and which
is the col?
-
Be very conscious of what player to use when. The supplied "player" is
not necessarily the one you want! Who knows the proper player for the moment?
-
To calculate a random number between 0 (inclusive) and N (non-inclusive),
use (int)(N*Math.random()).
-
Be sure to redraw the whole board, not just the one token that was placed.
This does not affect Tic-Tac-Toe, but does affect Othello.
-
Should the game halt before or after the view is notified of a win/lose/draw?
-
You should add skip control to your IRequestor. TurnControl can be set
so that setProceed() will skip the next player. Who can figure out whether
or not a player is to be skipped? Which player needs to tested for skipping?
-
How can you calculate (no if's please!) the value with which to update
the accumulator, when you only know which player won and not which player
you are? For instance, suppose player 0 won, but all you know is that you
are "modelPlayer". How can you calculate the proper value {-1, +1} to update
the accumulator with? Consider this: if modelPlayer=0 then value = +1, but
if modelPlayer = 1 then value = -1. Can you create a single formula will
properly calculate the value given the modelPlayer and the fact that player
0 has won?
.
Last Revised
Thursday, 03-Jun-2010 09:52:20 CDT
©2006 Stephen Wong and Dung Nguyen