The Abalone board consists of 61 cells which initially either contain 14 black marbles, 14 white marbles or nothing.

computer science

Description

Introduction 

The Abalone board consists of 61 cells which initially either contain 14 black marbles, 14 white marbles or nothing. In order to facilitate computational game play, the cells on the board can be referred to using a common notation as shown below. 


A model of any board game should enable the current state of the board to be read, displayed and manipulated based on the game rules. In the case of Abalone, it is important for a marble to move easily from one cell to a neighbouring one and to keep track of the number of marbles that have been pushed off the edge of the board. Marbles can move in six different directions; when they are on the boundary cells some of these movements result in the marbles being pushed off the board. 


Although there are many ways of modelling this board, an approach has been chosen for you in this practical. You are however, free to modify it or adopt alternative approaches in your project. We will have two classes: cell and board. Cells will have six pointers connecting them to adjacent cells in the six possible directions, such that any two neighbouring cells have two links in opposite directions connecting them. Cells should also keep details about their position and the marble that is currently on them (if any). In order to automate the creation and linking of cells, we will store them in 9 vectors corresponding to the rows of the board. The individual cells will also be accessible via a map using a string (key) which represents their location. The cells will be kept on the heap, hence they will be accessed via pointers. The task for this practical is to create, display and traverse such a board.


Exercise 

1. Create a project (C++ Application) for this exercise and add the given header files to it. 


2. Study the given cell.h header file then implement its functions in a corresponding source file. 


3. Study the given board.h header file then implement its functions in a corresponding source file. 


4. Instantiate a board instance then display it on the console in the main.cpp file. 


5. Demonstrate that your board has cells that are connected properly by traversing it horizontally and diagonally, in each case start with the cell at position A1.

Instruction Files
cell.h
787.0 Bytes
board.h
821.0 Bytes

Related Questions in computer science category