Nine Men's Morris AI Compo

Overview

This page is the repository for the files and information you will need to get up and running to compete in the Nine Men's Morris AI competition.

Game rules

This is the Nine Men's Morris board:

There are two players, white and black. Each starts with 9 pieces in their stack. White always begins play.

Game phases

There are two phases to a game. First is the placement phase, where each player alternates placing a piece onto the board from their stack. You can only place a piece on an unoccupied square. Also, if you manage to place three pieces in a row (ie. 0,1,2 or 1,4,7) you have formed a "mill". When you form a mill, you immediately get to remove one of your opponents pieces that is not itself in a mill. The removed piece is completely gone from the game.

The second phase is the movement phase, and begins when both players no longer have any pieces left in their stacks. In the movement phase you can move one of your pieces to an adjacent empty square. Note that forming a mill still allows you to remove an opponents piece.

Ending conditions

1. If any player has less than 3 pieces in the movement phase at any time, they lose.
2. If any player is unable to make a move in the movement phase, they lose.

Server

Overview

The server is a jar file and requires Java 1.4 or greater to be installed (it may work with <1.4, but I haven't tested it). If started with no arguments it is just a gui that allows two humans to play a game. It takes the following arguments to allow AI's to play:

-white programName - starts "programName" as white player
-black programName - starts "programName" as black player

Examples

java -jar server.jar -white "java RandPlayer" - starts the server with the Java random player playing as white.
java -jar server.jar -white myAI -black myAI - starts the server with myAI playing against itself.

Server API

Your AI communicates with the server using the default standard in/out files (ie. in Java System.out, System.in and in C++ printf(), scanf()). The communication is quite simple, and for a reference implementation you can check out the Java random player. Here are the steps:

1. Server sends your color as "0" for white, "1" for black, followed by newline.
2. AI sends it's name as a string, followed by newline.
3. Server sends current game state to game, which is as follows, all on one line, followed by a newline:

BoardState WhiteHolding BlackHolding MillingState

BoardState - A list of 24 pieces, either ["W","B","E"] representing a white piece, black piece or empty square respectively.
WhiteHolding - An integer representing the number of pieces that white is holding.
BlackHolding - An integer representing the number of pieces that black is holding.
MillingState - "1" if you are to mill a piece, "0" if you are not.

4. AI sends it's move. For placement it is the zero-indexed number of the square to place your piece on. For milling it is the zero-indexed number of the square to remove an opponents piece from. For movement it is the square to move from and square to move to seperated by a space (ie. "0 15"). All of these are followed by a newline.

Repeat 3 & 4 until end of game.

Downloads

Server jar - Main server jar file
Server source - only neccesary if you want to make changes.

Java Random Player

Source

Back to Projects page

Back to projects.