- Notifications
You must be signed in to change notification settings - Fork53
Programming assignments for MSU CSCI 366
License
msu-netlab/CSCI_366_Programming_Assignments
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Complete the following assignment individually.Submit your work on D2L into the "Programming Assignment 1" folder.
For a deeper discussion of the assignment and the code, please check out thisYouTube video.
In this programming assignment you will:
- clone and commit toGitHub repositories
- Learn how to build a C++ project usingCMake
- Learn how to test your code usinggoogletest
Your objective is to implement a basic version of theBattleshipgame.You will use the standard10x10 variation of the game.Here is an example ofonline implementationof the game.Note that the ships in that implementation have slightly different names.
Your implementation will be a client server architecture.This repository provides you with the header files for the client (player) and server implementations (src/Client.hpp
andsrc/Server.hpp
), client and server run times (src/client_main.cpp
andsrc/server_main.cpp
), and a suite oftests (test/tests.cpp
).Your job is to finish the implementation ofClient.cpp
andServer.cpp
to pass all the tests intests.cpp
.
The first step before the game begins is to create asetup board for each player, according to therules of the game.You will represent the board with a character array, where_
represents water and Carrier, Battleship, cRuiser,Submarine, and Destroyer fields are represented byC
,B
,R
,S
,D
respectively.For example, your board might be set up as follows:
CCCCC_____BBBB______RRR_______SSS_______D_________D_________________________________________________
Save these boards for both players asplayer_1.setup_board.txt
andplayer_2.setup_board .txt
.
To play the game, your implementation needs to exchange two types of messages -shot
andresult
.Theshot
message needs to communicate the grid location of salvo.Theresult
message needs to communicate whether the salvo was a hit, a miss, or if the shot was out of bounds.
You will represent both of these messages as JSON files that the client and server exchange via local disk storage.Assume that the x and y board coordinates are zero indexed at the top-left corner of the board and increase as you goright and down.
The following figure illustrates the operation of the program.(I kept the image from the lecture for continuity.)
The player fires ashot
by writing coordinates to aplayer_#.shot.json
file.The server reads the shot file, determines the result of the shot, and writes it intoplayer_#.result.json
.The player reads the result file and updates the result on its action boardplayer_#.action_board.json
.
To play Battleship you should first start the server by running therun-server
executable.Then start the player clients by running two instances of therun-client
executable.Unfortunately, the client and server executables will not do anything interesting until you implementClient.cpp
andServer.cpp
.As you progress in these implementations, your code will pass more and more tests intests.cpp
.When your code passes all the tests, you will be able to run the client and server executables to play the game.
I will awardone bonus point for each of the following:
Server throws an error if both players start with the same player number. (implementations and tests)
Server sends a different result when a ship is sunk. The client implementation notifies the player when they sink aship (implementation and tests)
Server detects when a game ends and returns the winner to both players. Player clients display the winner.(implementation and tests)
Submit your work on D2L into the "Programming Assignment 1" folder.
A text file containing a link to a GitHub repository with your solution
A text file alerting the TA if you implemented any of the bonus features, and if so, which ones
We will grade your submissions based on how many test cases intests.cpp
your solution passes.Note that for grading we will use out owntests.cpp
and full size setup board files.
About
Programming assignments for MSU CSCI 366
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.