Table of Contents

Reversi

Reversi is a two player game.

The Problem

Let us take a square playing board consisting of N x N square fields. The playing board is clearly delimited and board's edges do not neighbor each other. We have stones of two colors(traditionally black and white), one color per player. AT the beginning there are four stones in the middle of the board in this configuration:

BW
WB

Player whose turn it is, then places a stone so that it closes off his opponents row. These stones then turn into his. It works like this:

BW
WB
W

Player A placed his stone at the bottom, and this is the result:

BW
WW
W

It is now Player B's turn.

You can place stones either diagonally, horizontally or vertically. If a player cannot place a stone in a way that would take at least one stone, he loses his turn. The game ends when either the board is full, or neither player can place his piece. The objective is to have more stones than your opponent after the game ends.

The Assignment

You are to create a player, that will play properly (no exceptions and obeying the rules) and better than every other player.

Objectives

During this assignment we will see properties of following kinds of problems:

Evaluation

Just like in the whole course, foremost we value your effort. You do not have to worry about not finishing this course just because of this assignment if you at least try. However, during the upcoming weeks, there will be several control points, where we check your progress. At the end, all the algorithms will be compared by playing against the algorithms of all the other students and you should try to score as high as you can.

More details are here.

Submission

Submission is done in two phases:

  1. Upload of simple player, that can play according to the game rules
  2. Upload of sophisticated player for the tournament

Instructions for Running Reversi

  1. In your favourite IDE create project Reversi
  2. There is a quick walkthrough about creating project in NetBeans here.
  3. Add dependency on reversi.jar (get reversi.jar by unpacking reversi.jar.zip)
    1. google “How to add jar in $$$”, and replace $$$ with the name of your favourite IDE (NetBeans, Eclipse, Intellij Idea, …)
  4. Create package cz.cvut.agents.rph.reversi.players
  5. In this package create class PlayerXxxxxxxx, and replace Xxxxxxxx with your username - e.g. student with username novakja1 should name his player PlayerNovakja1 - NOTE: the name is case sensitive.
    1. This class should extend ReversiPlayer
    2. It should implement following methods:
      1. getName(), that returns your username
      2. makeNextMove(int[][] board), that returns your move as ReversiMove for given game state (defined in variable board). For finding out your player's colour, use method getMyColor() implemented in class ReversiPlayer.
      3. optionally you can override method init(…) for own initialization of the player. In that case, it is necessary to call super.init(…) as a first command in your method to ensure correct initialization of the player's parameters.
  6. JavaDoc for library reversi.jar is HERE
    1. For help with adding JavaDoc to the JAR library in you IDE use Google
    2. Source-code for the reversi.jar library will be available after the submission of simple players
  7. For running one game of one Reversi game, run cz.cvut.agents.rph.reversi.main.ReversiCreator
    1. You can define which players will be started by using their class names as arguments of method main(args)
    2. As testing oponent you can use already implmented player DummyPlayer, i.e. player that randomly selects valid moves
    3. So, our hypothetical student novakja1 should run the class ReversiCreator with parameters cz.cvut.agents.rph.reversi.players.PlayerNovakja1 cz.cvut.agents.rph.reversi.players.DummyPlayer

Tips & Tricks

You can set the time limit used for limitation of the reasoning time by setting the parameter timeout. This can be set by --timeout=XXX parameter of class ReversiCreator where XXX is maximal time (in milliseconds) for which your player can stay in method makeNextMove(). During debug and testing it can be helpful to set this parameter high, e.g. run the class ReversiCreator with parameters cz.cvut.agents.rph.reversi.players.PlayerNovakja1 cz.cvut.agents.rph.reversi.players.DummyPlayer --timeout=99000000

Source Code

Source code for the reversi.jar framework will be at your disposal after the submission of the siplme player.

For Download

[n/a: Access denied]