Earn Higher Grades With Instant Assignment Help.Ask Question!

C++ Programming
(5/5)

There are 2 players (player Black and player White) and an empty square game board (N*N). players take turn to place their pieces on empty cells of the board

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Computer Principles and C++ Programming

  • Requirements:
    • Filename: cpp;
    • Insert your name, student ID, and e-mail address as comments at the beginning of your source file;
    • Include suitable comments as documentation;
    • Free of compilation errors and warnings;
    • Only constant global variables allowed;
    • At least four functions (including main());

At least two functions should have array parameter(s).

Game Description

    Start condition:

  • There are 2 players (player Black and player White) and an empty square

game board (N*N).

  • Game stage:

    • The players take turn to place their pieces on empty cells of the board. (Player Black first place one black piece, then White and Black take turns, placing two pieces of their colors to empty positions each )

•     End condition:

  • The player who first connects six or more consecutive pieces of his/her color in a line (horizontally ↔, vertically ↕, or diagonally ⤡⤢) wins the game

  • When the board is full and no player connects six or more, it is a draw

game

Board Representation

  • Square board of size N*N where N is a constant integer

  • In each position, “B” means black piece; “W” means white piece; and “.” indicates an empty

  • The rows and columns are named in numbers 0, 1, 2,… and uppercase letters A, B, C, …

  • Code representation:

N = 19

•     board[0][0] => top-left

  • board[0][N-1] => top-right

  • board[N-1][0] => bottom-left

  • board[N-1][N-1] => bottom-right

  • When N is 19, the above refers to

A0, S0, A18, and S18 respectively.

  • We can simply modify the board

size by change a single variable N.

  1. Handle B’s inputs

When handling the input:

  • If the input is valid, update the board and

print it.

  • Else ask for correct input again by printing “Invalid Enter again!” until a valid input is entered.

A user input is valid if: (a) it is a proper board location within bounds, and (b) the input position is empty. Note that column letters must be uppercase. Lowercase letters are considered invalid.

Recall that N is not always 19 => The right

most column / bottom row is not always S

e.g.,

  • H14 will be invalid in the rest of this

game since it’s been occupied

  • H300 will be invalid since it’s out of

the boundary

  • b4 will be invalid since it is in

lowercase

  1. Ask white player to place the first

piece in this turn, handle W’s input,

check

  • (1) if the game hasn’t met the ending

condition, continue to step 4;

  • (2) else we end the game and

announce result.

  1. Ask white player to place the second

piece in this turn, handle W’s input,

check

  • (1) if the game hasn’t met the ending

condition, continue to step 5;

  • (2) else we end the game and

announce result. 

Program Flow

  1. Ask black player to place the first

piece in this turn, handle B’s input,

check

  • (1) if the game hasn’t met the ending

condition, continue to step 6;

  • (2) else we end the game and

announce result.

Attachments:
(5/5)

Expert's Answer

10 Times Downloaded

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

10 Times Downloads

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
562 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
738 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
635 Answers Hire Me