In this lab, we'll dive into the first crucial step of software development: understanding and defining the requirements and specifications of our project. We are going to walk through the development of a 'Connect Four' game to give you the skills to complete your Tic Tac Toe assessment.
Connect Four is a game in which the players choose a colour and then take turns dropping coloured tokens into a six-row, seven-column vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of four of one's own tokens.
Let's read the rules together
Then, let's have a couple of quick games
After fully understanding the game and its mechanics we can extract these into individual requirements and prioritise them for implementation.
Prioritise core functionality and things you NEED in order to play, and leave requirements such as win/draw conditions towards the end.
"What is the first thing we need in order to play the game?"
Requirement 1 - The game is played on a 6x7 grid
"What else do we need to play?"
Requirement 1 - The game must have a vertical grid of 7 columns and 6 rows.
Requirement 2 - The game is played with two players
Requirement 3 - Each player must have a disc of a specific color (e.g. red and yellow)
There are many more questions that can be asked once you have everything you need to play. E.g.
"How does the game start?"
"What do players actually do?"
"How does a player win?"
"How else can the game end?"
Complete the prioritised list of requirements with a partner
We will then share and compare with the class
We will discuss any differences
We will try to come up with a class list of requirements on the board
In this part of the lesson, we focus on converting the identified requirements of our Connect Four game into precise, technical specifications. This step is crucial as it bridges the gap between what we want our software to do and how we plan to build it.
Example Requirement:
"Players must be able to drop discs into the columns."
Thought Process:
Consider what this requirement entails in terms of programming.
We need a way for players to select a column, a method to place a disc in that column, and a check to ensure the column isn't full.
What does "dropping a disc mean" in a 2D list? What happens when a disc is placed in a full column?
Draft the Specification:
"Player chooses a column of the 2D list (1 to 7). We iterate from the bottom of the list (row 6) upwards until we find an empty spot. If there are no empty places, prompt the player to choose another column."
Note:
Much of what is written in the above specification relies on the implementation of other requirements (such as the 2D list for the grid).
Read over your requirements a few times and think about the data structures needed before beginning.
Choose a requirement from our "class list" and break off with a partner
Attempt to turn this requirement into a detailed specification
We will then share and compare with the class
We will discuss any differences
We will try to come up with a class list of specifications on the board