COMP 303 Fall 2008
Milestone 2 - Game Engine and AI
Version 1.0 - 24 September 2008
To provide an opportunity to gain additional experience and skills with:
- Interface and class design
- Dynamic dispatch
- Class hierarchy design
- The Observer design pattern
- Test suite design
- Classes with complex behavior
- Use of state diagrams
Required Problem 1
Implement the model module (see the project overview).
This module should be made accessible through a class
model.GameEngine that will control the state and playing of
the game for one human and one computer player. This state should
include, for example, the cards played, the state of the deck, the
score of each player, which player is the dealer, etc. This module
should have no GUI, but should provide an API allowing clients
to "virtually" play the game, i.e., change the state of the object to
allow it to control the playing one complete game (which involves
multiple hands). Example of methods in your GameEngine API
would typically include newGame(), discard(...),
It is your responsibility to design a module with an interface meeting
the principles seen in class, and that will make it as convenient as
possible to create the user interface.
Besides the main GameEngine class, you can create as many
helper classes as necessary to solve the problem.
The only "hard" requirement for the GameEngine class is that
is plays the role of the Subject in the Observer design pattern.
You must provide a set of unit tests that demonstrate and test your
Game module. You should have unit tests for each public method of your
GameEngine class (except trivial getters and setters). In
addition, you must provide a driver program (i.e. a
main method) that simulates playing a game using
GameEngine. Note that the role for the Driver is not to
allows humans to play interactively, but merely to demonstrate you
GameEngine API in action. For example, Driver code would
typically look like:
GameEngine lEngine = new GameEngine();
System.out.println("Begin new game");
and so on.
Required Problem 2
Implement the AI module (see the project overview).
This module provides behavior for the computer player. This behavior
provides a way for the game to automatically handle decisions that a
human player would normally take (i.e., what card to discard, when to
knock, etc). Isolate the decision-making behavior a computer
player object should have in an interface, and implement it. Note that
the behavior of the computer player should be honest, i.e.,
decisions should not be made using any information that could not be
obtained by a human player.
designing your AI module, you may want to consider the following
The design of the AI module should not allow the system to break the
rules of the game or to cheat. Note that the "artificial
intelligence" in computer players does not have to be "smart" or rely
on advanced AI techniques. However, it should be reasonable and
- What decisions do players need to make?
- For each of the above decisions, what type of information about
the game would help in making a decision (cards seen to date,
current hand, etc.)
- What type of information should not be available to
- How much coupling should there be between the computer players and
the game engine, etc.
To make the game more exciting, and to obtain more points on your
project. Only tackle bonus problems if you can complete the basic
requirements. Bonus marks will be at the discretion of the markers
based on the sophistication level of the bonus features, up to a
maximum of 20% of the total mark for the milestone. The following are
ideas for extension. Other ideas may be considered: please discuss
them with the instructor.
Bonus Problem A - Gambling Mode
Support vegas-style playing, where players exchange money based on
their score, and where it is possible to play multiple games in one
Bonus Problem B - Statistics
Accumulate stats about the performance of the player in persistent
Bonus Problem C - Difficulty Levels
Support different computer players with different skill levels.
Bonus Problem D - Autoplay
Allow two computer players to play against each other.
- A zip file containing all your code and class
files, including tests. Please submit
through WebCT. See the schedule for the deadline.
- A UML state diagram modeling the GameEngine class. The
diagram must be in jpeg format.
- A text file (ASCII) with maximum one page of text explaining your main design,
addressing the design points mentioned in "Required Problem", and explaining the rational
behind the AI "behavior" you have implemented.
This part will be marked out of 35 and will be worth 35% of the
overall project grade. It will also be the backbone for your GUI so it is important that you do it well. In marking your
project, we will looking for the following points:
- The quality of your module's interface (based on the principles seen
- Overall quality and design of the code
- Quality and thoroughness of the test cases
- Quality of the state diagram