The Hexareversi Project

Two good project implementations

Two teams of students agreed to have their excellent projects displayed on the course webpage:

  1. Othexo by Kevin Koh and Kiat Boon;
  2. Hexareversi Team 46 by Li Yier;
  3. Hexareversi Team 77 by Lu Si Hong and Ling Xiao Xiong Shaun.

Reversi

The Reversi game (also known as Othello) is a two player game played on a square 8 * 8 board with 64 positions. The players move alternately and try to get as many pieces of their colour as possible. They put a new piece next to existing ones and all pieces of the opposite colour which are between the new and an old of the own colour are turned into the own colour. A move must always be made the way that at least one piece is turned.

The game ends when the board is full or when no more legal move is possible. The winner is then the player who owns the largest number of pieces.

Hexareversi

The task of the project is to work on an existing program for Hexagonal Reversi and to improve it. The Hexagonal Reversi differs from the standard one in two aspects:

  1. The players move on a hexagonal grid where where each field has six neighbours in place of eight.
  2. The players have the right to pass; if both players pass one after the other, the game ends.

Your task

The goal of the project is to improve the existing implementation on http://www.comp.nus.edu.sg/~gem1501/year1314sem2/project/hexareversi.html with respect to the two following aspects:

  1. Improve the user interface;
  2. Provide a good playing algorithm;
  3. Provide a tournament option where the computer plays two strategies against each other for 10 games.

You will be working in teams of two.

Your strategy will be assessed by playing against some default opponents, the three random opponents implemented and a Mystery Player of better playing strength.

The user interface

You are free to make your own interface from scratch or reuse and improve the basic one provided to you. For examples of the endless possibilites of HTML5, CSS3 and Javascript, you can for instance look at the Mozilla Developer Network's Demo Studio (this is for illustrative purposes only, you are not required to develop a professional-looking application!).

You can also extend the game the way you want as long as you keep a version of your playing algorithm which respects the rules we defined (so that you can enter the tournament).

The playing algorithm

In order to make the tournament possible, it is necessary to agree on a common interface so that your playing algorithm can be called, sent the current contents of the board and can return a move.

Each playing algorithm must be contained in an object (without entering into the details of Javascript, we can turn the YourPlayer function into an object), having a function called nextMove:

function YourPlayer(side) {
    this.nextMove = function(board) {

        // this is where the magic happens

        return move;
    };
}
This function is currently set to some default in the file default.js and this reference to default.js should.

At the creation time of the YourPlayer object instance, the side parameter receives 1 or -1, respectively for player X or player Y.

The board parameter is an array. The entries have the following indices:

            11    12    13    14    15

         21    22    23    24    25    26

      31    32    33    34    35    36    37

   41    42    43    44    45    46    47    48

51    52    53    54    55    56    57    58    59

   62    63    64    65    66    67    68    69

      73    74    75    76    77    78    79

         84    85    86    87    88    89

            95    96    97    98    99

The neighbours of a cell c are the cells with the indices c+1, c+10, c+11, c-1, c-10, c-11. For example, the cell 75 has the neighbours 64, 65, 74, 76, 85, 86 which are in the row immediately above, the same row and the row immediatly below.

 -11   -10
    \ /
-1 — c — +1
    / \
 +10   +11

The entries in the board contain either a 0 (when the cell is free), a +1 (when there is a piece of player X), a -1 (when there is a piece of player Y), or undefined (when it is an invalid coordinate).

Given a variable c containing a cell number, one can use a conditional statement of the form:

if (c in board) {
    statement;
}

to make sure that the statement command is only done when c is indeed a cell of the board.

The return value of nextMove() must be a number indicating in which position the algorithm puts its piece. It can return 0 to indicate that it passes its turn.

The tournament option

The tournament option should enable to compare two of the given strategies by letting them play 10 games against each other (each strategy plays 5 times as Player X and 5 times as Player Y). The plays need not to be displayed, but a result summarising the scores should be given. This result should contain the following information:

You can use this option to check how well your players play against the random players and you can also write your programs such that you can compare the strength of your strategy with that of a fellow team.

For being able to do the latter, your strategy should be in an extra js-file on your homepage, different from the file of your game, and it should be possible to include it into the games of other players in order to play against it. See Your Implementation below for details.

Strategies

There are three model players preimplemented in the file "randommove.js". These players can be described as follows:

Your Implementation

Your implementation consits of two files.

Your Presentation

You will give a 5 minute presentation on your project in Week 13 (last week of the semester) on Thursday 17 April 2014. You can show some slides which you put on your homepage as a pdf-file. Please keep the time-frame.

Assessment

When evaluating, we will give scores for the quality of your project. Marks will be given for the following items.

The total number of marks obtainable for the project is 10 (out of 100 overall marks for the course).

Please keep all the information on your homepage available. When you are ready, please send an email with your team number, the names of your team members, the url of your material (including the programs) to kister@comp.nus.edu.sg and fstephan@comp.nus.edu.sg; you can also include the material as attachment to the email in the case that you want to be sure that it reaches us.

Deadline: Wednesday 16 April 2014 24:00 hrs

Deadline is Midnight from Wednesday to Thursday, send your email by then.