Othello game script

hi im in a video game design class and our group is making a othello type game. and were trying to figure out how to script the gameplay in java. how to make it look for spaces that are white between two black pieces and turn them black. if any one has any advice for any othello type gameplay mechanics let me know thanks. :slight_smile:

The process of actually setting the black or white colour of the board squares depends on the implementation (ie, whether you are colouring the squares in or using counter objects coloured black and white, or whatever).

A good way to model the board is as an array of counter objects. If you are using a standard 8x8 board, you will need a 64-element array, although the index numbers will go from 0 to 63.

Assuming you start numbering from the top left corner and continue rightwards and downwards, you can convert a column/row pair into an array index quite easily:-

var index: int = row * 8 + column;

…and converting back is just the reverse:-

var column: int = index % 8;
var row: int = index / 8;

Getting the neighbours of a square is also quite easy. For example, the square above will be at index - 8, the square below at index + 8, etc. To search along a row, column or diagonal, you just need to keep generating each successive square’s neighbour in the same direction until a square of the original colour is found (in which case there’s a line) or until a blank square is found (in which case nothing happens).

The AI for Othello could be pretty formidable, depending on how sophisticated you want it to be. I think you’ll find a few websites giving tips on how to go about this.