-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.c
61 lines (56 loc) · 1.44 KB
/
board.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/***********************************************************************
* COSC1076 - Advanced Programming Techniques
* Semester 2 2015 Assignment #1
* Full Name : Abdi Farah
* Student Number : 543707
* Course Code : MEC2004
* Program Code : MSc
***********************************************************************/
#include "board.h"
#include "player.h"
/**
* @file board.c contains implementations of functions related to the game
* board.
**/
/**
* @param board the board to reset the contents of
**/
void initialise_board(enum cell_contents board[BOARDHEIGHT][BOARDWIDTH])
{
int i, j;
for(i=0; i < BOARDHEIGHT; i++)
for(j=0; j < BOARDWIDTH; j++)
board[i][j] = C_EMPTY;
}
/**
* In this requirement you are required to display the game board.
* The game board should be displayed as shown on the first page of the
* assignment specification.
* @param board the board to display
**/
void display_board(enum cell_contents board[BOARDHEIGHT][BOARDWIDTH])
{
puts("This is the state of the board:");
int i;
for(i=0; i < BOARDWIDTH; i++)
printf("%3i|", i+1);
puts("\n----------------------------"); //7 * 4 -
for(i=0; i < BOARDHEIGHT; i++){
int j;
for(j=0; j < BOARDWIDTH; j++){
switch(board[i][j]){
case C_RED:
printf(" %s |", RED_TOKEN);
break;
case C_WHITE:
printf(" %s |", WHITE_TOKEN);
break;
case C_EMPTY:
default:
printf(" |");
break;
}
}
printf("\n");
}
}