logo Use SA10RAM to get 10%* Discount.
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Rubina KhatoonFinance
(5/5)

934 Answers

Hire Me
expert
Allen CrumppTechnical writing
(5/5)

800 Answers

Hire Me
expert
Abhishek WadhwaEngineering
(5/5)

542 Answers

Hire Me
expert
Aidan CampbellTechnical writing
(5/5)

697 Answers

Hire Me
C++ Programming

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.

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. 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

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

334 Experts Online