The game state: The BoardModel contains information about the current state of the game, including rules (width, height, k, gravity), and piece locations. There are get() methods for the rules of the game (width, height...). To obtain a model with a new piece inserted, call the placePiece(Point p, byte player) method. This returns a new BoardModel object with a piece in the desired location (or as if it were dropped at the desired location when gravity is on). The pieces are stored in a 2D array (called 'pieces') of bytes and can be retrieved with the getSpace(int x, int y) method, which returns a byte 1 for player 1, 2 for player 2, or 0 when empty. The major index (i) indicates the column; the minor index (j) the row. Enumeration starts at the lower left corner from 0 ((0,0) is the lower left corner). So, for a 7x6 (width,height) board, lower left=(0,0), upper right=(6,5), upper left=(0,5), lower right=(6,0). There are conveniece methods hasMovesLeft() and winner() which you may use. equals() is also implemented. It will return true when the game *state* is the same. The lastMove field is not considered part of the state. --Note: most of the BoardModel member variables are currently public. This was intended for simplicity and speed, but was probably a bad choice and will likely be removed in the future. It is recommended to use the 'get' methods such as 'getSpace(int x, int y) instead of directly accessing 'pieces[x][y]'. That is, any direct member access is depricated, and will only remain for the Winter quarter. Writing an AI: Students should extend the CKPlayer abstract class to make their own AI. It is constructed with its player number (1 or 2), and a blank example BoardModel which contains the rules of the current game (width, height...). The fact that the constructor receives a blank board does not indicate that the player will be going first. Player 1 always goes first (in the tournament, two games are played between A and B AIs: one where AAI is player 1 and BAI is player 2, and one where AAI is player 2 and BAI is player 1). DummyAI.java is a [trivial] AI which can be used as an example (but please, don't call your AI DummyAI :-/ ). The AI will have getMove(BoardModel state) called. You can use the getLastMove() method to determine what the opponent's move was (unless it is the first move). The argument 'deadline' in the two parameter version is how long you have to make a move, in milliseconds (e.g. deadline=1000 means 1 second). It should return a move in the form of a java.awt.Point(). You are not allowed to modify any files in the connectK package; the source is just a convenience. You should give your AI class a unique name, probably your UCI net username (e.g. "Panteater.class" for the user "Peter Anteater"). GUI: To run the shell (assumes the current directory is contains the 'connectK' project directory; for Eclipse you should be in the "bin" directory [when the project is set up with seperate source and binary directories): java connectK.ConnectKGUI To run the shell with the DummyAI: java connectK.ConnectKGUI connectK.DummyAI.class To run the shell with your AI: java connectK.ConnectKGUI YourAI.class (replace 'YourAI.class' with your AI class filename. This assumes your AI class file is in the current directory and is not part of a package) There is also a "new" menu in the game. You can add your AI to the dropdown of AI options by clicking the "Add AI" button. This way you can play one AI agains another and watch. This assumes your AI is part of the "connectK" package and is in the "connectK" directory. Tournament: You can also test your AI in a tournament fashion against other versions. java connectK.Tournament AI1.class AI2.class AI3.class Each version will have to be in a different class. Keep in mind that if you're using helper classes which are shared between versions that any static variables are also shared. You can watch the games happen. After all the games are played (n^2 - n games), the scores will be printed for each player (higher is better). Currently the tournament defaults to a standard Connect4 game (7x6 4 in a row, gravity on). Any questions, feel free to email me: 'avanbusk@uci.edu' -Ale