Question
Need help: The first program: a console-only version of Connect Four One of your two programs will allow you to play one game of Connect
Need help:
The first program: a console-only version of Connect Four
One of your two programs will allow you to play one game of Connect Four using only console interaction (i.e., no networks or sockets). The user is repeatedly shown the current state of the game whose turn it is and what the board looks like. The board should always be shown in the following format:
1 2 3 4 5 6 7 . . . . . . . . . . . . . . . . . . . . . . . R . . . . . . Y R . . . . R R Y . Y .
You have some latitude in how you ask the user to specify a move, but it needs to be clear what the user should do. Do not assume that your user will know what to type; tell them (briefly). Columns should be selected by typing a number between 1 (the far-left column) and 7 (the far-right).
When the user is asked to specify a move but an invalid one is specified (such as dropping into a column that is full), an error message should be printed and the user should be asked again to specify a move. In general, erroneous input at the console should not cause the program to crash; it should simply cause the user to be asked to specify his or her move again.
The game proceeds, one move at a time, until the game ends, at which point the program ends.
The second program: a networked version of Connect Four
Your second program will instead allow you to play a game of Connect Four via a network, by connecting to a server that I've provided. Your program always acts as a client.
When this program starts, the user will need to specify the host (either an IP address, such as 192.168.1.101, or a hostname, such as www.ics.uci.edu) where a Connect Four server is running, along with the port on which that server is listening.
Additionally, the user should be asked to specify a username. The username can be anything the user would like, except it cannot contain whitespace characters (e.g., spaces or tabs). So, for example, boo or HappyTonight are legitimate usernames, but Hello There is not.
Once the user has specified where to connect, the program should attempt to connect to the server. If the connection is unsuccessful, print an error message specifying why and end the program. If, on the other hand, the connection is successful, the game should proceed, with the client acting as the red player (and moving first) and the server which acts as an artificial intelligence acting as the yellow player. For red player moves, the user should specify the move at the console, as in your first program; for yellow player moves, the program should instead communicate with the server and let the server determine what move should be made.
As in the first program, the game proceeds, one move at a time, until the game ends, at which point the program ends.
The requirements You will actually be writing two programs to satisfy this project's requirements. The vast majority of the oode will be shared between the two programs. In fact, one of your goals is to find a way to reuse as much of it as possible; if you find yourself copying and pasting code betwoeen the pmgrams, you should instead consider a way to use the put the code in one place and use it in both The first program: a console-only version of Connect Four One of your two programs will allow you to play one geme of Conneci Four using crily corisole interaction (i.e, no rielwurks cr suckels). The user is repeatedly shown t he current slale of the sparriewhose turn it is ard what the board ooks like. The board should a/ays be shown in the following forma: You have some atitude in how you ask the user o specify left column) and (the tar-night) nove, but it needs o be clear what the user should do. Do not ess rne that your user will know what o ype: ell them bre y Columns should b selected by yping ? number between 1 the r hen he user s asked o spec a mo e but an m a d one s e?ed such as dro ng Into a co urrin he 1s u an error message should be pr med en he user should be as e again o spec a move n eneral er oneous mp a console should not cause the program to crash; it should simply cause the user to be asked to specity his or her move again The game proceeds, one move at a time, untl the game ends, at which point the program ends. The second program: a networked version of Connect Four Your soccnd program will instead allow you to play a game of Connect Four via a network, by connccting to a sorver that l'vc provided. Your prcgram always acts as a cien when this progr m starts, the user will need to speci he host lethe?an P ?ddress, such as 92.168.1.101. or a os name, suches v v csu du where a onnect Four sener s running, along with the p to which th sen er s steri Additionally, the user should be asked to specify a username. The usemame can be anything the user would like, excapt it cannot contain whitespace characters (e.g, spaces or tabs). So, for example, boo or Happy Tonight are legitimate usemames, but Hello There is not nce he user has specified where o connect he pro ram shou d atter to connect to t e server lf he connection is unsuccess onn an error message spec n wn and end the program on otherhand he conne ion s success u hegam should proceed, with the clent acting as the red player (and moving tirst) and the senver-which acts as an artcs intelgencecting as the yellnw player For red player moves, the user shnuld specity the move at the conscle, as in ynur tirst prngram for yellow player ITIowes, the program should inslead cumriunitale with the server ak let the server delerrriine whal iuve shiculd be made As in the first prograrm the game proceeds, one move at a time, uritil the garme eds, at which point the prograri ends The requirements You will actually be writing two programs to satisfy this project's requirements. The vast majority of the oode will be shared between the two programs. In fact, one of your goals is to find a way to reuse as much of it as possible; if you find yourself copying and pasting code betwoeen the pmgrams, you should instead consider a way to use the put the code in one place and use it in both The first program: a console-only version of Connect Four One of your two programs will allow you to play one geme of Conneci Four using crily corisole interaction (i.e, no rielwurks cr suckels). The user is repeatedly shown t he current slale of the sparriewhose turn it is ard what the board ooks like. The board should a/ays be shown in the following forma: You have some atitude in how you ask the user o specify left column) and (the tar-night) nove, but it needs o be clear what the user should do. Do not ess rne that your user will know what o ype: ell them bre y Columns should b selected by yping ? number between 1 the r hen he user s asked o spec a mo e but an m a d one s e?ed such as dro ng Into a co urrin he 1s u an error message should be pr med en he user should be as e again o spec a move n eneral er oneous mp a console should not cause the program to crash; it should simply cause the user to be asked to specity his or her move again The game proceeds, one move at a time, untl the game ends, at which point the program ends. The second program: a networked version of Connect Four Your soccnd program will instead allow you to play a game of Connect Four via a network, by connccting to a sorver that l'vc provided. Your prcgram always acts as a cien when this progr m starts, the user will need to speci he host lethe?an P ?ddress, such as 92.168.1.101. or a os name, suches v v csu du where a onnect Four sener s running, along with the p to which th sen er s steri Additionally, the user should be asked to specify a username. The usemame can be anything the user would like, excapt it cannot contain whitespace characters (e.g, spaces or tabs). So, for example, boo or Happy Tonight are legitimate usemames, but Hello There is not nce he user has specified where o connect he pro ram shou d atter to connect to t e server lf he connection is unsuccess onn an error message spec n wn and end the program on otherhand he conne ion s success u hegam should proceed, with the clent acting as the red player (and moving tirst) and the senver-which acts as an artcs intelgencecting as the yellnw player For red player moves, the user shnuld specity the move at the conscle, as in ynur tirst prngram for yellow player ITIowes, the program should inslead cumriunitale with the server ak let the server delerrriine whal iuve shiculd be made As in the first prograrm the game proceeds, one move at a time, uritil the garme eds, at which point the prograri endsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started