Starting from:

$34.99

SENG1120 Assignment 2 Solution

NOTE: The important information about submission and code specifics at the end of this assignment specification.

INTRODUCTION
Your task in this assignment is to produce a new version of the traditional board game Connect Four (see https://www.mathsisfun.com/games/connect4.html). In the original game, a board with 7 columns and 6 rows is placed vertically. Two players with different coloured pieces choose a column and put a piece in it, which falls to the bottom. The winner is that who gets 4 pieces with the same colour connected in a straight line (horizontally, vertically, or diagonally).

The game variation for this assignment is a bit different. The winner must connect 4 pieces vertically or horizontally only. The diagonals are not considered.

ASSIGNMENT CORE TASK (10.0 Marks)
The board will be implemented as an array of seven stacks. Each stack should be implemented as taught (using Node, LinkedList and LStack classes).

As usual, the main file will be provided. You will need to implement the logic of the game inside the class GameplayStack: how to add pieces, checking for the winner or tie after each piece is added to the board, and displaying either the message "X Wins", "O Wins", or "Game Tie". You will also need to display the board at the end.

The board should be displayed as below:


# #
# #
# #
# O #
# O X O X X #
# O X X X O O #
#######################
1 2 3 4 5 6 7 You will note that the game has no real user interface when played with the Connect4Demo.cpp or Connect4Template.cpp – using these files you will ONLY see the final state. Your submission must work the same way.

Interface functions, for all board tests and manipulation .

BONUS TASK (2.0 Marks)
SENG6120 students are REQUIRED to complete the Template Option as part of their Core Task • (2.0 mark) Implement the Task using class templates; your code needs to work with the GamePiece class and the Connect4Template.cpp demo that was provided. You will need to update the supplied makefile to use the Connect4Template.cpp demo file; there is an alternate SOURCES line in the make file – swap the remark # between the two SOURCES lines.


SUBMISSION
Make sure your code works with the files supplied, and DO NOT change them. For marking, we will add the demo file to the project and compile everything using the makefile, together with your own files. If it does not compile or run, your mark will be zero.

Your submission should be made using the Assignments section of the course Blackboard site. Incorrectly submitted assignments will not be marked. You should provide the .h and .cpp/.hpp files related to all classes in the assignment. Also, if necessary, provide a readme.txt file containing instructions for the marker. Each program file should have a proper header section including your name, course and student number, and your code should be properly documented.

Compress all your files into a single .zip file, using your student number as the filename. For example, if your student number is c9876543, you would name your submission:
c9876543.zip

If you have attempted the Bonus Requirement (or you are a 6120 student), please include a blank text file in the same folder as your source files, simply called Bonus.txt – this is to make it clear to the marker that you are attempting this.

Submit by selecting the Assignment 2 link that will be found in the Assessment section on Blackboard.

Remember that your code should compile and run correctly using GNU C++. Test it using Cygwin.


This assignment is worth 10.0 marks of your final result for the course (including bonus marks).





The sequence of moves in the demo file were played at
https://www.mathsisfun.com/games/connect4.html and are present in the demo files so you can test your code. The final configuration for each of them is (X = blue; O = red):

Game 1: Game 2:



O Wins # #
# # # O # # O #
# X X O #
# O X X X O #
####################### 1 2 3 4 5 6 7 X Wins
# #
# #
# #
# X #
# X X O O O O #
# X X X O O O X #
#######################
1 2 3 4 5 6 7


Game 3:


Game Tie
# X O O X X O O #
# O X O O O X X #
# X O O X O X O #
# O O X O O X X #
# X X X O X O O #
# O X X X O X X #
####################### 1 2 3 4 5 6 7


GOOD LUCK












Dan and Alex

More products