Computers and Technology

Write a program to implement the game connect-n. Connect-n is like Connect4 except instead of having the board be a constant 6 X 7 we will allow the user to enter the size of the board they would like to play on. In addition we will also allow the user to choose how many pieces in a row are necessary to win. The game is played as follows. Two players take turns dropping their pieces into a column until either player gets N of their pieces in a row either horizontally vertically, or diagonally, or until their or no more spaces to play. 1. Your program must accept 3 command line parameters in this order: number of rows, number of columns, number of pieces in a row to win 1. If the user does not enter enough arguments or enters too many arguments your program should tell them the proper usage of your program and terminate 1. You may find the exit function helpful 2. The user should be allowed to create an unwinable game rmpl a board that is 3 X.3 but roqes4 ices in a row 1o 2. Your program should not allow the user to make an impossible play but should continue to ask the user for a play until a valid play is entered 1. Invalid plays consist of plays made outside the board or in to columns that are already full. The token used to represent Player 1 is X. The token used to represent Player 2 is O, a capitol oh and not a zero After the game is over the winner should be declared or if there is no winner a tie should be declared You must split your code up into at least 2 files. 1. I personally had 4 separate c files You must submit a make file named Makefile that when run compiles your program The executable created by your make file should be named connectn. out Hints This is your first "large" program. It took me around 300 lines of code to complete. You will want to break your problem down into many small manageable functions to make the problem easier to deal with 1.
I also recommend testing each function your write as you go along to help you locate your errors early I had the following functions defined in my solution and they give a pretty good ordering of how you should write you should solve this problem
1. read_args 2. create_board, print_board, destroy board 3. play_game, get_play, play_is_valid 4. game_over, game_won, row_win, col_win, diag_win, right_diag_win, left_diag_win. 10.
1../connectn. out
1.Not enough arguments entered
2.Usage connectn. out num_rows num_columns
number_of_pieces_in_a_row_needed_to _win 2../connectn. out 1 2 3 4 5
1.Too many arguments entered
2.Usage connectn. out num_rows num_columns
number_of_pieces_in_a_row_needed_to _win 3../connectn. out 3 3 3
2** * 1** * 0** *
01 2
Enter a column between 0 and 2 to play in: 0 2** *
1** *
0X* *
01 2
Enter a column between 0 and 2 to play in: 1 2** *
1** *
0XO *
01 2
Enter a column between 0 and 2 to play in: 0 2** *
1X* *
0XO *
01 2
Enter a column between 0 and 2 to play in: 0 2O* *
1X* *
0XO *
01 2
Enter a column between 0 and 2 to play in: 0 Enter a column between 0 and 2 to play in: 0 Enter a column between 0 and 2 to play in: -2 Enter a column between 0 and 2 to play in: 4 Enter a column between 0 and 2 to play in: 1 2O* *
1XX *
0XO * 01 2
Enter a column between 0 and 2 to play in: 2 2O* *
1XX *
0XO O
01 2
Enter a column between 0 and 2 to play in: 2 2O* *
1XX X
0XO O
01 2 Player 1 Won!
4../connectn. out 1 2 3 0* *
01
Enter a column between 0 and 1 to play in: 0 0X *
01
Enter a column between 0 and 1 to play in: 1 0X O
01 Tie game!

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:30, sheram2010
Acomputer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a series of stored . the processing unit of most modern computers is a(n) . the instructions that tell a computer how to carry out a task are referred to as computer , which are distributed as software. computers run three main types of software: software, system software, and development tools. an example of system software is a computer system, which is essentially the master controller for all the activities that a digital device performs. digital devices are constructed using tiny electronic components that represent data bits as electrical signals. the system unit houses the system board, which contains several circuits made from semiconducting materials. computers come in three popular form factors: component, , and slate. many of today's digital devices operate on battery power supplied by ion batteries. battery life and lifespan can be extended by following good battery management practices.
Answers: 3
image
Computers and Technology, 22.06.2019 14:30, SKYBLUE1015
What percentage of companies is projected to use social media to locate new employees in 2012
Answers: 2
image
Computers and Technology, 23.06.2019 00:30, devenybates
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
image
Computers and Technology, 23.06.2019 03:30, mem81
How can you repin an image on your pinterest pin board a. click on the "repin" button b. click on the "add pin" button c. click on the "upload a pin" button d. click on the "save pin" button.
Answers: 2
Do you know the correct answer?
Write a program to implement the game connect-n. Connect-n is like Connect4 except instead of having...

Questions in other subjects: