CUNY BC C Program Run and Compile Connect Four Building A Text Interface Code Writing
Question Description
Throughout the course of this semester, you will be building Connect Four. If you are not familiar with this game, you can find the rules here: https://en.wikipedia.org/wiki/Connect_Four
You can play the game here: https://www.mathsisfun.com/games/connect4.html
We will not be building a graphical use interface for this game (that is not the focus of this course) but we will be building a text interface to this game.
For this assignment, we will be creating our project and getting some of the structure in place.
Most computer games have a particular structure, whether guess a number or Battlefront II. They start with some initialization set up the data structures that model the game world. Then there is the game loop a (nearly) infinite loop that accepts user input, updates the state of the game world, and updates the display. Finally, there is the teardown sequence that happens at game exit.
https://en.wikipedia.org/wiki/Video_game_programming#Game_structure
Game Loop
Connect Four is a game that alternates player 1 and player 2. You should keep track of whose turn it is next.
Your assignment: Create a program that models the structure above.
Create functions:
- Initialization print Setting up the game. Ask each player their name.
- Teardown print Destroying the game
- Accept Input accept a letter for which column of the game we are going to drop a disc into. Valid letters are A-G (7 columns). You should designate a letter for Quit the game. Input must be returned from this function.
- Update the state of the world pass the input data to this function. Since we do not have a world right now, choosing A is the winning move, all other letters make the game continue. This method must not print anything. It only does calculations. Results from here update the global state.
- Display the state of the world Print the result calculated in the state of the world. Later, this should print the board.
- Main call initialization, then loop until a flag is set (game over or a player quit), calling accept input, update and display. Outside of the loop, call teardown.
Make variables to define the size of the board (width and height). These can be global variables. Other global variables might include player names, which player should play next and did anyone quit yet?
You must submit buildable C source code
Hints:
Dont write too much code my solution is about 70 lines of code. If you go TOO much over that, you have done it really wrong. Shorter isnt better, but longer isnt better either.
I suggest using scanf for input and printf for output.
Write extra helper functions if you find yourself copy/pasting code.
One mistake that people often make is to have AcceptInput call UpdateWorld which then calls DisplayState. This is not correct. Each of these functions are called by the game loop.
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."