a f b e c d Figure 1 Figure 2 Figure 3

Similar documents
Programming Standards: You must conform to good programming/documentation standards. Some specifics:

CS ) PROGRAMMING ASSIGNMENT 11:00 PM 11:00 PM

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

3. When you process a largest recent earthquake query, you should print out:

CS 2704 Project 2: Elevator Simulation Fall 1999

Decision Logic: if, if else, switch, Boolean conditions and variables

CS 2704 Project 3 Spring 2000

CS 2604 Minor Project 1 DRAFT Fall 2000

CISC 3130 Data Structures Spring 2018

CS 2704 Project 1 Spring 2001

Programming Assignment #3 Event Driven Simulation

CS 1044 Project 1 Fall 2011

Fundamental Concepts: array of structures, string objects, searching and sorting. Static Inventory Maintenance Program

CS 1044 Program 6 Summer I dimension ??????

CS 2604 Minor Project 1 Summer 2000

CS 202, Fall 2017 Homework #4 Balanced Search Trees and Hashing Due Date: December 18, 2017

Our second exam is Thursday, November 10. Note that it will not be possible to get all the homework submissions graded before the exam.

The Program Specification:

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help

gcc o driver std=c99 -Wall driver.c bigmesa.c

CS 1044 Project 5 Fall 2009

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

A rectangle in the xy-plane, whose sides are parallel to the coordinate axes can be fully specified by giving the coordinates of two opposite corners:

CS 111X - Fall Test 1

Assignment 4. Overview. Prof. Stewart Weiss. CSci 335 Software Design and Analysis III Assignment 4

Introduction to Programming System Design CSCI 455x (4 Units)

CS 142 Style Guide Grading and Details

CISC 3130 Data Structures Fall 2018

CS503 Advanced Programming I CS305 Computer Algorithms I

Syllabus CS 301: Data Structures Spring 2015

INFS 2150 (Section A) Fall 2018

Practical 2: Ray Tracing

In either case, remember to delete each array that you allocate.

CS 2604 Minor Project 3 Movie Recommender System Fall Braveheart Braveheart. The Patriot

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

Each line will contain a string ("even" or "odd"), followed by one or more spaces, followed by a nonnegative integer.

Given that much information about two such rectangles, it is possible to determine whether they intersect.

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

Here is a C function that will print a selected block of bytes from such a memory block, using an array-based view of the necessary logic:

Programming Assignment HW4: CPU Scheduling v03/17/19 6 PM Deadline March 28th, 2019, 8 PM. Late deadline with penalty March 29th, 2019, 8 PM

CMPE 180A Data Structures and Algorithms in C++ Spring 2018

Short Answer Questions (40 points)

Our second exam is Monday, April 3. Note that it will not be possible to get all the homework submissions graded before the exam.

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 2 Assigned: September 7, 2016 Due: Wednesday, September 14, 2016 by 2:30 pm

CSE 100: GRAPH SEARCH

// Initially NULL, points to the dynamically allocated array of bytes. uint8_t *data;

Prelim 2 Solution. CS 2110, April 26, 2016, 5:30 PM

CS 241 Data Organization using C

CpSc 1111 Lab 9 2-D Arrays

Introduction to UNIX

CS 2604 Minor Project 3 DRAFT Summer 2000

CSC D84 Assignment 2 Game Trees and Mini-Max

Prelim 2. CS 2110, April 26, 2016, 5:30 PM Total Question True/False Complexity Heaps Trees Graphs Max Score Grader

Advanced Web 2. Course Information. Instructor Information. Course Objectives

CS 2210a Data Structures and Algorithms Assignment 5 Solving a Labyrinth Due Date: December 6, 11:59 pm Total marks: 20

Homework 1: Programming Component Routing Packets Within a Structured Peer-to-Peer (P2P) Network Overlay VERSION 1.1

Prelim 2 Solution. CS 2110, April 26, 2016, 7:30 PM

CS 3030 Scripting Languages Syllabus

Important Project Dates

CSE 131 Introduction to Computer Science Fall Exam II

(the bubble footer is automatically inserted into this space)

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

gcc o driver std=c99 -Wall driver.c everynth.c

CS483 Design and Analysis of Algorithms

Pointer Casts and Data Accesses

Problem Set 4. Part A: Due Tuesday, November 2nd

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace

Out: April 19, 2017 Due: April 26, 2017 (Wednesday, Reading/Study Day, no late work accepted after Friday)

Problem 1 (programming) will be completed in pairs assigned by the instructor. Problem 2 (analysis) must be completed individually.

Assignment3 CS206 Intro to Data Structures Fall Part 1 (50 pts) due: October 13, :59pm Part 2 (150 pts) due: October 20, :59pm

COMP 412, Fall 2018 Lab 1: A Front End for ILOC

Linear Algebra Math 203 section 003 Fall 2018

Multiple-Key Indexing

COMP 401 COURSE OVERVIEW

CMPUT 396 Sliding Tile Puzzle

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

General Course Information. Catalogue Description. Objectives

CS150 Assignment 7 DNA!

SeaMonkey for PC. Getting Started Adding Links Adding Colors, Images, and Style Loading into D2L

You must pass the final exam to pass the course.

CSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT

EECE.2160: ECE Application Programming Spring 2017

EE 352 Lab 3 The Search Is On

CS 200, Section 1, Programming I, Fall 2017 College of Arts & Sciences Syllabus

Programming Assignment #4 Arrays and Pointers

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

New York University Computer Science Department Courant Institute of Mathematical Sciences

CSCI 1301: Introduction to Computing and Programming Spring 2018 Project 3: Hangman 2.0 (A Word Guessing Game)

CS 206 Introduction to Computer Science II

Advanced Web Topics II MMC 6278 (4 credit hours) Fall 2014

EECE.2160: ECE Application Programming Spring 2019

Programming Assignment HW5: CPU Scheduling draft v04/02/18 4 PM Deadline April 7th, 2018, 5 PM. Late deadline with penalty April 9th, 2018, 5 PM

Project 4: Implementing Malloc Introduction & Problem statement

CS 3114 Data Structures and Algorithms DRAFT Project 2: BST Generic

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 8 Assigned: October 26, 2016 Due: November 2, 2016 by 2:30pm

CS 375 UNIX System Programming Spring 2014 Syllabus

Project 1: How to Make One Dollar

Com S 227 Spring 2018 Assignment points Due Date: Thursday, September 27, 11:59 pm (midnight) "Late" deadline: Friday, September 28, 11:59 pm

You will provide an implementation for a test driver and for a C function that satisfies the conditions stated in the header comment:

Transcription:

CS2604 Fall 2001 PROGRAMMING ASSIGNMENT #4: Maze Generator Due Wednesday, December 5 @ 11:00 PM for 125 points Early bonus date: Tuesday, December 4 @ 11:00 PM for 13 point bonus Late date: Thursday, December 6 at 11:00 PM with a 13 point penalty Assignment: The goal of this project is to write a program that will automatically generate and solve mazes. Each time the program is run, it will generate and print a new random maze and solution. You will use the disjoint set (union-find) data structure, depth-first search (DFS), and breadth-first search (BFS). See Sections 6.2 and 11.3 in the textbook. Generating a Maze: Conceptually, to generate a maze, first start with a grid of rooms with walls between them. The grid contains r rows and c columns for a total of r*c rooms. For example, Figure 1 is a 4x4 grid of 16 rooms. The missing walls at the top left and bottom right of the maze border indicate the start and finish rooms of the maze. a f b e c d Figure 1 Figure 2 Figure 3 Now, begin removing interior walls to connect adjacent rooms. The difficultly in generating a good maze is in choosing which walls to remove. Walls should be removed to achieve the following maze characteristics: 1. Randomized: To generate unpredictable different mazes, walls should be selected randomly as candidates for removal. For randomization, you must use the rand() function to generate random numbers, and srand() to initially seed the random number generator with a unique value, e.g. srand((unsigned)time(null)). 2. Single solution: There should be only one path between the start room and the finish room. Unnecessarily removing too many walls will make the maze too easy to solve. Therefore, a wall should not be removed if the two rooms on either side of the wall are already connected by some other path. For example, in Figure 2, the wall between a and f should not be removed because walls have previously been removed that create a path between a and f through b,c,d,e. Use the disjoint set data structure to determine room connected-ness. 3. Fully connected: Enough walls must be removed so that every room is reachable from the start room. There must be no rooms or areas that are completely blocked off from the rest of the maze. Figure 3 shows an example generated maze. Solving the Maze: After generating a maze, your program should then solve the maze first using DFS and then again using BFS. Each search algorithm will begin at the start room and search for the finish room by traversing wall openings. The search should terminate as soon as the finish room is

found. For each search algorithm, you will output the order in which rooms where visited and indicate the shortest solution path from start to finish. Design: You will likely represent the maze as a graph data structure, where rooms are nodes and removed walls are edges between nodes. Since the size of the graph is known at startup, a 2 dimensional array-based implementation that mimics the grid structure may work well. To randomly select walls for removal, you will also need to maintain a separate list of walls eligible for removal. As randomly selected walls are removed from the maze or determined to be ineligible for removal (because of rule 2 above), they are eliminated from the wall list. This places a tight upper bound on the number of iterations of the wall-removal loop. You must use the disjoint set data structure for the union and find operations on rooms when generating the maze. It is required that you implement the weighted union rule and the path compression technique for maximum efficiency. Rooms that are connected by some path are in the same set. The find operation reveals whether two rooms are already connected by some path. When removing a wall, the union operation is used to join the two sets together. The maze generator is done when there is only one set left, indicating that all rooms are connected. The disjoint set data structure enables efficient processing of the union and find operations, so that maze generation is fast. Input: The program should be named maze and should accept the number of rows r and columns c of the maze as command-line arguments. If no command line arguments are given, it should default to 20 rows by 20 columns. The following invocation would create a maze that is 10 rows by 20 columns: % maze 10 20 Output: The program should print to standard-out the maze, then the DFS solution, then the BFS solution. The maze is printed in ASCII using the vertical bar and dash - characters to represent walls, + for corners, and space character for rooms and removed walls. The start and finish rooms should have exterior openings as shown. For the DFS and BFS solutions, the maze should be output twice for each algorithm. The first maze output for each algorithm should show the order that the rooms were visited by the algorithm. The maze should be printed exactly as above except that rooms should be printed with the low-order digit of the visitation order number. The start room is 0. Unvisited rooms should remain a space character. The second maze output for each algorithm should show the shortest solution path, using hash # character for rooms and wall openings on the solution path. You will need to view the output in a fixed-width font. The program should output <pre> as the first line. This will enable you to view your mazes correctly in a web browser by directing standard output to a file on the command line: % maze 10 20 > mymaze.html

Following is sample output for the maze in Figure 3: <pre> DFS: 0 1 2 3 4 5 8 9 6 7 0 # +#+-+-+ + # +#+ +-+ + ### ### +-+#+#+#+ ### # BFS: 0 1 3 2 7 4 5 0 1 9 6 8 2 # +#+-+-+ + # +#+ +-+ + ### ### +-+#+#+#+ ### #

Programming Standards: You must conform to good programming/documentation standards, as described in the Elements of Programming Style. Some specifics: You must include a header comment, preceding main(), specifying the compiler and operating system used and the date completed. Your header comment must describe what your program does; don't just plagiarize language from this spec. You must include a comment explaining the purpose of every variable or named constant you use in your program. You must use meaningful identifier names that suggest the meaning or purpose of the constant, variable, function, etc. Always use named constants or enumerated types instead of literal constants in the code. Precede every major block of your code with a comment explaining its purpose. You don't have to describe how it works unless you do something so sneaky it deserves special recognition. You must use indentation and blank lines to make control structures more readable. Precede each function and/or class method with a header comment describing what the function does, the logical significance of each parameter (if any), and pre- and postconditions. Decompose your design logically, identifying which components should be objects and what operations should be encapsulated for each. Neither the GTAs nor the instructors will help any student debug an implementation, unless it is properly documented and exhibits good programming style. Be sure to begin your internal documentation right from the start. You may only use code you have written, either specifically for this project or for earlier programs, or code taken from the textbook. Note that the textbook code is not designed for the specific purpose of this assignment, and is therefore likely to require modification. It may, however, provide a useful starting point. You may not use code from STL, MFC, or a similar library in your program. Testing: Sample data files will be posted to the website to help you test your program. This are not the data files that will be used in grading your program. While the test data provided should be useful, you should also do testing on your own test data to ensure that your program works correctly. Deliverables: You will submit this project electronically. In particular, you will create a zip'ed archive file containing the following items (and nothing else): all source code files necessary to build an executable either the project workspace files (.dsw and.dsp) for Visual C++ users, or a makefile for g++ users.

Windows users should be sure to use a modern zip tool which preserves long file names. A suitable freeware command-line zip tool will be posted on the course website. UNIX users should submit a gzip'ed and tar'ed file. Once you have assembled the archive file for submission, for your own protection, please move it to a location other than your development directory, unzip the contents, build an executable, and test that executable on at least one input file. Failure to do this may result in delayed evaluation of your program, and a loss of points. You will submit your project to the automated Curator server. The instructions and necessary software are available at: http:ei.cs.vt.edu/~eags/curatorguides.html. If you make multiple submissions, only your last submission will be evaluated. Pledge: Your project submission must include a statement, pledging your conformance to the Honor Code requirements for this course. Specifically, you must include the following pledge statement in the header comment preceding the function main() in your program. The text of the pledge will also be posted online. On my honor: - I have not used C++ language code obtained from another student, or any other unauthorized source, either modified or unmodified. - All C++ language code and documentation used in my program is either my original work, or was derived, by me, from the source code published in the textbook for this course. - I have not discussed coding details about this project with anyone other than my instructor, ACM/UPE tutors or the GTAs assigned to this course. I understand that I may discuss the concepts of this program with other students, and that another student may help me debug my program so long as neither of us writes anything during the discussion or modifies any computer file during the discussion. I have violated neither the spirit nor letter of this restriction. Programs that do not contain this pledge will not be graded.