EECS268:Lab4

From ITTC
Jump to: navigation, search
Navigation
Home
Information

Syllabus
Schedule

Classwork

Labs
Submitting Work


Due time

This lab is due Friday July 3rd by 11:59pm

Lab conduct

  • Do not use any unauthorized aid, such sites like rentacoder or chegg to obtain answers
  • Do not use code provided by another student
  • Do not reuse code (by you or anyone) from prior semesters
  • If you need help, seek it from:
    • Your lab TA.
    • Me, Dr. Gibbons, my email is jwgibbo@ku.edu / jwgibbo@gmail.com
  • If equipment you don't own (e.g. cycle servers) needs attention or you're having account issues put in a ticket!

Restrictions

You are forbidden from using standard library data structures (e.g. std::vector) in the lab. Any data structures used must be your implementations.

Overview

Beware of the Blob!

As Halloween approaches, monsters and creepy crawlies are coming out of the woodwork. In this lab, the Blob is loose and you will figure out with parts of the city will and won't be consumed.

You'll be given a file with a map of the city and the starting point of the Blob. Your program will use recursion and backtracking to figure how far the Blob will spread.


File Format

<numRows> <numCols>
<Blob startRow> <Blob startCol>
<map characters>
  • Num rows and columns indicate the maps dimensions
  • Start row and column are where Blob begins
  • The row and columns coordinates range from 0 to (numRows-1) and 0 to (numCols-1)
  • The top left of the map would be considered 0,0

The map consists of:

  • Streets represented by spaces ('S')
    • The Blob can only move through streets and sewers
  • Buildings are represented by '#'
  • Sewers are represented by @
    • You will need to do some pre-processing on the file to find the locations of all sewers before your Blob simulation begins
    • All sewers are considered adjacent

A file is invalid and the program should end with an error message if...

  • if file doesn't exist
  • if numRows are less than 1
  • if numCols are less than 1
  • if start position is not within range

You may assume the map characters match the parameters given above.

Blob Moving Rules

  • The Blob starts at the start position
  • The Blob only spreads orthogonally (up, right, down, or left) not diagonally
    • See special rules of sewers
  • You must check for valid directions to spread in the order: up, right, down, left
  • You cannot spread through the Buildings
    • See special rules of sewers
  • Sewers
    • If the Blob is on a sewer space, and has tried to spread in all other directions, it will spread into the sewer, which allows it to move to all connected sewer spaces one at a time
    • Once the Blob moves through a sewer it continues to move as normal

Output

After receiving a file from the command-line you will output to where the Blob spread. As the Blob spreads, you will marks its path with 'B's. You must keep the sewers as '@' in the output

I've provided a few examples below.

Additional Requirements

Do not use a stack object to solve the problem; use recursion.

Emailing Your Submission

Once you have created the tarball with your submission files, email it to your TA. The email subject line must look like "[EECS 268] SubmissionName":

[EECS 268] Lab 0#

Note that the subject should be exactly like the line above. Do not leave out any of the spaces, or the bracket characters ("[" and "]"). In the body of your email, include your name and student ID.

Rubric

  • 70% Correctly spreads the Blob
    • 55% Blob spreads through streets
    • 15% Blob spreads into sewers then continue moving as normal
  • 20% Code design
  • 10% Code style and documentation

Sample Runs

Input file 1

4 4
3 0
##S#
#SS#
##S#
SSS#

Output 1

##B#
#BB#
##B#
BBB#

Input file 2

8 8
0 0
SSSSSSS#
######S#
@SSSSSS#
########
###S####
@SSS#SS#
#S######
########

Output 2

8 8
0 0
BBBBBBB#
######B#
@BBBBBB#
########
###B####
@BBB#SS#
#B######
########