these 2 functions are linked with each other. #define MAX_BOARD_SIZE 12 // Players #define PLAYER_EMPTY 0 #define PLAYER_BLACK 1 #define PLAYER_WHITE 2 int board_size; int current_player = PLAYER_BLACK; char board[MAX_BOARD_SIZE][MAX_BOARD_SIZE]; int main(void); void announce_winner(void); unsigned int count_discs(int player); void announce_winner(void) { int black_count = count_discs(PLAYER_BLACK); int white_count = count_discs(PLAYER_WHITE); if (white_count > black_count) { printf("The game is a win for WHITE!\n"); white_count += count_discs(PLAYER_EMP

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

convert c code to mips

these 2 functions are linked with each other.

#define MAX_BOARD_SIZE 12

// Players

#define PLAYER_EMPTY 0

#define PLAYER_BLACK 1

#define PLAYER_WHITE 2

int board_size;

int current_player = PLAYER_BLACK;

char board[MAX_BOARD_SIZE][MAX_BOARD_SIZE];

int main(void);

void announce_winner(void);

unsigned int count_discs(int player);

void announce_winner(void) {

int black_count = count_discs(PLAYER_BLACK);

int white_count = count_discs(PLAYER_WHITE);

 

if (white_count > black_count) {

printf("The game is a win for WHITE!\n");

white_count += count_discs(PLAYER_EMPTY);

} else if (black_count > white_count) {

printf("The game is a win for BLACK!\n");

black_count += count_discs(PLAYER_EMPTY);

} else {

printf("The game is a tie! Wow!\n");

}

 

printf("Score for black: %d, for white: %d.\n", black_count, white_count);

}

unsigned int count_discs(int player) {

int count = 0;

for (int row = 0; row < board_size; ++row) {

for (int col = 0; col < board_size; ++col) {

if (board[row][col] == player) {

count++;

}

}

}

return count;

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education