Question: Please try to write a code in C for the provided game following the template below. The game can be found on http://www.othelloonline.org/ and the
Please try to write a code in C for the provided game following the template below.



The game can be found on http://www.othelloonline.org/



and the template:
#include//Standard Library #include //Board Size Constant #define BOARD_SIZE 8 //Board Space Constants #define EMPTY_SPACE 0 #define P1_SPACE 1 #define P2_SPACE 2 //Player Constants #define PLAYER1 1 #define PLAYER2 2 //Alignment Constants #define HOR_ALIGN 3 #define VERT_ALIGN 4 #define DIAG_ALIGN 5 // function prototypes: // All these three printBoard function prototypes are equivalent void printBoard(int board[BOARD_SIZE][BOARD_SIZE]); // OK // void printBoard(int board[][BOARD_SIZE]); // Good // void printBoard(int (* board)[BOARD_SIZE]); // Good int validateInput(); // All these three printMove function prototypes are equivalent int playMove(int x, int y, int PLAYER, int board[BOARD_SIZE][BOARD_SIZE]); // OK // int playMove(int x, int y, int PLAYER, int board[][BOARD_SIZE]); // Good //int playMove(int x, int y, int PLAYER, int (* board)[BOARD_SIZE]); // Good int gameOver(int board[BOARD_SIZE][BOARD_SIZE]); int getAlignment(int x1, int y1, int x2, int y2); int main(void){ // ..... int board[BOARD_SIZE][BOARD_SIZE]; //Game Board Variable // use a do-while or while loop here // do{ // ... //Getting Player Input int x, y; printf(" "); printf("Enter X coordinate: "); x = validateInput(); printf("Enter Y coordinate: "); y = validateInput(); playMove(x, y, playersTurn, board); // Place Move on Board printBoard(board); // function call // }while(!gameOver(board)); //Loop while the game is not over return 0; } void printBoard(int board[BOARD_SIZE][BOARD_SIZE]) // OK // void printBoard(int board[][BOARD_SIZE]) // Good //void printBoard(int (* board)[BOARD_SIZE]) // Good { //Display the game board here } //To be changed in XGame Week 5 Assignment int playMove(int x, int y, int PLAYER, int board[BOARD_SIZE][BOARD_SIZE]) // OK // int playMove(int x, int y, int PLAYER, int board[][BOARD_SIZE]) // Good // int playMove(int x, int y, int PLAYER, int (* board)[BOARD_SIZE]) // Good { //Set board to either P1_SPACE or P2_SPACE here return 1; } int gameOver(int board[BOARD_SIZE][BOARD_SIZE]){ //Find if there are any valid moves to be played by either PLAYER1 or PLAYER2 //If there are any valid moves, return 1 //else, return 0 return 0 } int getAlignment(int x1, int y1, int x2, int y2){ //Find alignment between two points //Return HOR_ALIGN, VERT_ALIGN, or DIAG_ALIGN return 0; } int validateInput(){ int num; // validate input here return num; }
This week you will be modifying your playMove function to only accept certain moves. The game you are making is othello (if you have not guessed already). The objective of this game is to have the most pieces of your color on the board when the game finishes. You gain points by placing pieces of your color on the board and flanking (capturing) your opponent's pieces. The rules are as follows: 1. A piece (either a 'B' or 'W' in the case of our game) cannot be placed on top of a previously placed piece. The space must be empty. 2. If on your turn you cannot outflank and flip at least one opposing piece, your turn is forfeited and your opponent moves again. If a move is available to you, you may not forfeit your turn. 3. A piece may outflank any number of pieces in one or more rows in any number of directions at the same time horizontally, vertically or diagonally. (A row is defined as one or more pieces in a continuous straight line). See Figures 1 and 2. These Disc discs placed flipped Figure 1 here Figure 2 4. You may not skip over your own color piece to outflank an opposing piece. (See Figure
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
