Project
News
Updates will show up here.
- Go through this checklist before submitting your code.
- There was a critical bug in the
PPlayer class in the method getLegalMoves. Many students had corrected the bug in their own submissions. An updated PPlayer.java file is here. The main download archive is also updated.
- There was a bug in the
PBoard class. An updated PBoard.java file is here. The main download archive is also updated.
- Javadocs are now available here. Check out the methods of the
PBoard class.
- A sample greedy player is available here. It shows how to clone a board and apply a move to get to the next state.
- Submission instructions are updated.
Goal
The main goal of the project for this course is to give you a chance to play
around with some of the AI algorithms discussed in class, in the context of
a fun, large problem.
The game selected for this year's competition is called Pushers.
The game
The game is played on an 8x8 chessboard. There are two types of pieces on the board. Pushers (larger in size) and pushees. The game starts with one row of pushers behind a row of pushees for each player. The goal of the game is to reach the other side of the board with one of your pieces.
Pushers can move on their own in any of the three forward directions. Pushees cannot move on their own and can only be pushed in any of the forward directions. Pushing can only be done in the relative direction of the pieces. The pusher will stay in its place after the push.
A player can take an opponent's piece by moving or pushing one of her pieces over the opponent's piece. A player wins the game if she gets to the opposite side with any of her pieces, or when the opponent runs out of pushers (i.e. cannot move anything).
The rules are simple, but the gameplay is complex enough to favour players with good tactics and long-term strategy.
The client/server software
Download the Java server and client software here.
During the tournament, the game will be played with each player running on a
different computer (to avoid contention for CPU). The players will
communicate with the server via TCP socket connections. Of course, the server
and clients can all be run on the same machine too.
The server and an example client are provided. Please see
the README.txt file for a description of the included files.
To run a server and two random players on the local machine:
- Download and extract the code. In the directory containing the code, compile with
javac boardgame/*.java pushers/*.java
- Launch a server to listen on port 8123:
java boardgame.Server -p 8123
The server GUI appears.
- In a different console, launch the first player to connect with:
java boardgame.Client pushers.PRandomPlayer localhost 8123
- In yet another console, launch the second player:
java boardgame.Client pushers.PRandomPlayer localhost 8123
There are shell scripts provided in the package to do the above tasks automatically. The game starts as soon as both clients are connected.
The server software also allows for locally running clients
to be launched from the GUI (using the Lunch menu), for humans to play against software players
or other humans, and for game log files to be viewed.
See the README.txt file for more information on running the client
and server.
Implementing a player
A framework is provided to help you implement your player. It handles
communication with the server and maintains a copy of the current game
board. You are also provided with the source code for a simple random
player (the class pushers.PRandomPlayer),
which you may use as a starting point.
To implement a player, create a class that impelments pushers.PPlayer. You need only define two methods:
- a default constructor which MUST include your McGill ID
- the
chooseMove() method
Then your new PPlayer subclass can be passed as an argument to the
client software.
A simple player will look like this:
////////////////////////////////////////////////////////////////////////
package mypackage;
import pushers.PPlayer;
public class MyPlayer extends PPlayer {
/** A default constructor is needed so that the client
software can create a MyPlayer object. */
public MyPlayer() {
// The string passed to the Player constructor will be
// used to identify the player to the server. In your
// final version, this should be your McGill ID.
super("MY-MCGILL-ID");
}
/** Choose a move to play */
public Move chooseMove(Board theboard) {
// Pick a move to play somehow...
return move;
}
}
////////////////////////////////////////////////////////////////////////
To run this player instead of the random player, pass it as the
argument to the client
software: java boardgame.Client mypackage.MyPlayer localhost 8123
Documentation:
The boardgame.Player and pushers.PPlayer classes also provides other methods. See the source code for boardgame.Player,
pushers.PBoard and pushers.PPlayer for
further documentation.
You are not required to use the provided PBoard and
PMove
classes in your code. It may be preferable to represent the board in
a way better adapted to the particular algorithms you will use, since
these classes were written with the server in mind. In fact, you are not required to use any of the client software provided
as long as your player correctly communicates with the server and runs
on the SOCS lab machines.
Java remains the recommended language, but use whatever you
are most comfortable with. (If you're mainly worried about
performance,
do some research before making a decision.)
You are reminded that your code must run on Linux; if you have any special requirements, ask.
Advice
Some hints on writing a winning player:
- Play the game against the random player, your player and/or
other people to get a feel for the strategy required.
-
Start small and build up your player incrementally. Here is a natural
progression of steps:
-
Figure out an evaluation function for board positions.
-
Encode a minimax-like algorithm with fixed depth (or iterative
deepening).
-
Insert alpha-beta pruning.
-
Add whatever other heuristics you think may help.
-
Devise ways to tune the heuristics, manually or, better yet, using learning.
- Test your code after each significant change. Make sure you
always have a working program.
- Experiment to see what effect your changes have. Leave yourself time for tweaking your player and trying out different approaches.
- Ask questions if you
- have trouble understanding the provided code,
- need help getting started,
- get stuck,
- are wondering if your ideas will work,
- or have any existential questions.
Requirements and evaluation
What to submit:
You should hand in two components:
- An implementation of your player program.
- A written report documenting your approach. (Required for the final submission)
Both of these components are mandatory in order to receive a
passing grade on the project.
The minimum requirement is for your code to be able to defeat the random player
that is provided as an example.
It is mandatory that you have a working and
documented program. Programs that are not working will not
receive credit. Programs that are not documented will not receive full credit.
Special files:
Make sure submit these files with your program:
- A
README.txt file which includes any extra requirements or necessary information about your code.
- A
runclient.sh script that runs you player. For players implemented in java, there is a sample script provided in the package. Make sure you change the name to run your player instead of the random player. This will help us automate the tournament.
Due date:
The due date for your final code and report is
April 8, 2011 (the last day of classes). Results will be posted on the website as they become available.
Language:
Your implementation can be carried out in the programming language of
your choice. The recommended language is Java and supporting code
for that language is supplied to simplify your task. You
should focus on providing 'intelligence' for your player.
Limitations:
There will be a 10 second time limit for each move. If you fail to return a move in that time, you will loose the game. The size of the submitted file should not exceed 10MB. You code cannot use the network except for the communication with the server. Your code should run on the machines located in Trottier room 3120 (Krieble lab). These are the specification of the machines (to the best of our knowledge):
- Intel Core(TM)2 Duo CPU @ 2.40GHz
- 2G RAM
- Running 32 bit Linux
Report:
The report must be typed and grammatically sound. The suggested length is 5-8 pages (~300 words per page), but the most important part is to produce a report that is clear and concise. The report must include the following required components:
-
An explanation of how your program works, and a motivation for
your approach.
-
A brief description of the theoretical basis of the approach
(about a half-page, in most cases); references to the text of
other documents, such as the textbook, are appropriate but not
absolutely necessary. If you use algorithms from other sources, briefly describe the algorithm and give a citation to your source.
-
A summary of the advantages and disadvantages of your approach,
expected failure modes, or weaknesses of your program.
-
If you tried other approaches during the course of the project,
summarize them briefly and discuss how they compared to your final
approach.
-
A brief description (max. half page) of how you would go about
improving your player (e.g. by introducing other AI techniques,
changing internal representation etc.).
Tournament:
We will hold a competition between all the programs submitted by
students in the class. The competition will play every player
against many other players in a tournament fashion, once as White and once as Black, in order
to ensure fairness.
Academic integrity:
This is an individual project. The
exchange of ideas regarding the game is encouraged, but sharing of
code and reports is forbidden and will be treated as cheating.
Please see the syllabus and www.mcgill.ca/integrity for
more information.
Submission instructions
A single zip file with your McGill ID as the name (e.g. 1234567.zip) should be send to the address comp.424.2011[A.T]gmail.com. Make sure again that you have set your McGIll ID in the code as instucted above, and that you have updated the runclient.sh script to run your own player.
All the players will be tested against the random player before the
tournament and we will try to contact you if we have trouble running your
player. If you have any special requirements (e.g. persistent data), include them in your email in addition to mentioning it in your README file.