Question: Create a Kotlin program using double arrays which simulates the Connect Four game. You will have a user play against the computer (like Rock Paper

Create a Kotlin program using double arrays which simulates the "Connect Four" game. You will have a user play against the computer (like Rock Paper Scissors).

The program should print out a "board" for the user to see on EVERY turn, by clearing the screen first and then printing the board and the "menu" for the user to select his turn.

Playing will be done in the command console.

The program should:

prompt the user for their turn,

get the user's selection, (Column 1 through 8)

place the piece in the double array,

reprint the screen,

Internally check to see if the user won and quit if they did with a "win" message

Show the computer's turn

get the computer's selection, (random number for Column 1 through 8)

place the piece in the double array,

reprint the screen

Internally check to see if the computer won and quit if they did with a "win" message

repeat

The board should be an 8 x 8 board of playable positions. A piece can only go into one of 8 slots (columns). A piece must "slide" down to the last available space. It cannot "hang" in mid air.

After each turn, you need to check to see if you or the computer has won with the last move. This means that there are 4 pieces in a row anywhere on the board: horizontally, vertically, or diagonally.

Example Board:

1 2 3 4 5 6 7 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0 . . . . . . . X . . . . . . . Select a column to place your piece (X):

Extra Credit:

20 pts: Make it "pretty" (connectfour_pretty.kt) using the extended ASCII character set like this:

  1  2  3  4  5  6  7  8    .  .  .  .  .  .  .  .   .  .  .  .  .  .  .  .   .  .  .  .  .  .  .  .   .  .  .  .  .  .  .  .   .  .  .  .  .  .  .  .   .  .  .  .  .  .  .  .   .  .  .  .  .  .  .  .       .  .  .  .  .  .   Select a column to place your piece ():

20 pts: Make a separate Player vs. Player version (connectfour_pvp.kt)

20 pts: Make a separate Computer vs. Computer version (connectfour_cvc.kt)

Rubric

Connect Four

This criterion is linked to a Learning OutcomeInitialize the double array correctly 8x8

This criterion is linked to a Learning OutcomeLoop until a winner is declared

This criterion is linked to a Learning OutcomePrints game "board" after every turn

Must be printed on every turn - - both computer and user's turn. Must print out menu/prompt for next turn. Must print out the user and computer board pieces in the proper places

This criterion is linked to a Learning OutcomeAsk for User's turn - 1-8 columns

This criterion is linked to a Learning OutcomeUser or Computer turn "slides" piece into the correct place on top of existing pieces.

This criterion is linked to a Learning OutcomeVertical Win Checking - Computer and User

This criterion is linked to a Learning OutcomeHorizontal Win Checking - Computer and User

This criterion is linked to a Learning OutcomeSW to NE Diagonal Win Checking - Computer and User

This criterion is linked to a Learning OutcomeNW to SE Diagonal Win Checking - Computer and User

This criterion is linked to a Learning OutcomeUser cannot enter a non-existent column

This criterion is linked to a Learning OutcomeIndenting and Code Formatting

This criterion is linked to a Learning OutcomeExtra Credit - Pretty Board (20 pts)

This criterion is linked to a Learning OutcomeExtra Credit - Player v Player Game (20 pts)

This criterion is linked to a Learning OutcomeExtra Credit - Computer v Computer Game (20 pts)

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!