Question: C programming : Othello Game //*************************************************** // Filename: othello.c #include othello.h // Displays the board (as SIZE x SIZE grid) on console void displayBoard( char

C programming : Othello Game

//***************************************************

// Filename: othello.c

#include "othello.h"

// Displays the board (as SIZE x SIZE grid) on console

void displayBoard(char board[][SIZE])

{

printf(" ");

for (int i = 0; i < SIZE; i++) {

printf((i == 0 ? "%5d" : "%3d"), i+1);

}

printf(" ");

for (int i = 0; i < SIZE; i++) {

printf("%2d", i+1);

for (int j = 0; j < SIZE; j++) {

printf("%3c", board[i][j]);

}

printf(" ");

}

printf(" ");

}

// Initializes the board with start configuration of discs (see project specs)

void initializeBoard(char board[][SIZE])

{

// REPLACE THIS WITH YOUR IMPLEMENTATION

}

// Returns true if moving the disc to location row,col is valid; else returns false

bool isValidMove(char board[][SIZE], int row, int col, char disc)

{

if(row<0 || row>SIZE-1 || col<0 || col>SIZE-1 || board[row][col]==disc){

return false;

}else{

return true;

}

}

// Places the disc at location row,col and flips the opponent discs as needed

void placeDiscAt(char board[][SIZE], int row, int col, char disc){

// COMPLETE THIS FUNCTION

}

// Returns true if a valid move for disc is available; else returns false

bool isValidMoveAvailable(char board[][SIZE], char disc){

// REPLACE THIS WITH YOUR IMPLEMENTATION

}

// Returns true if the board is fully occupied with discs; else returns false

bool isBoardFull(char board[][SIZE]){

// REPLACE THIS WITH YOUR IMPLEMENTATION

}

// Returns true if either the board is full or a valid move is not available for either disc

bool isGameOver(char board[][SIZE]){

// REPLACE THIS WITH YOUR IMPLEMENTATION

}

// If there is a winner, it returns the disc (BLACK or WHITE) associated with the winner.

// In case of a tie, it returns EMPTY

char checkWinner(char board[][SIZE]){

// REPLACE THIS WITH YOUR IMPLEMENTATION

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!