Prog04a -...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //------------------------------------------------------------------------// Name: George Corser// Program: CSC 375 Program 4 (Prog04.cpp)// Due Date: Friday, April 3, 2009 (04/3/2009)// Compiler: Bloodshed Dev-C++ 4.9.9.2//// Comments: MAZE GENERATION (PARENT-POINTER GENERAL TREE)// This program generates a maze based on command line input.//// prog04 rseed rowsize colsize//// where rseed is the random-number seed, rowsize is the number// of rows in the maze, and colsize is the number of columns.// Connections within the maze are determined by a parent-pointer// general tree representation implemented as an array.// The array is a dynamically allocated general tree, called gt.// Let D = (rowsize * colsize) be the dimension of the array (gt).// gt[0-(D-1)] - the array indexes of the node's parent// gt[D-(2D-1)] - north walls (0=open, 1=closed)// gt[2D-(3D-1)] - south walls (0=open, 1=closed)// gt[3D-(4D-1)] - east walls (0=open, 1=closed)// gt[4D-(5D-1)] - west walls (0=open, 1=closed)////------------------------------------------------------------------------#include <iostream> // for cout calls#include <iomanip> // for cout formatting, setw()#include <cstdlib> // for random number generation#include <stdlib.h>#define TRUE 1#define FALSE 0#define ROOT -1#define RAND_ROW 0+(int) (((float) rowsize) *rand()/(RAND_MAX+1.0))#define RAND_COL 0+(int) (((float) colsize) *rand()/(RAND_MAX+1.0))#define RAND_NEIGHBOR 0+(int) (((float) (4)) *rand()/(RAND_MAX+1.0)) #define NORTH 0 // the neighbor is 0, 1, 2, or 3, where...#define SOUTH 1 // 0-north, 1-south, 2-east, 3-west#define EAST 2#define WEST 3//#include "uf.h" // with weighted union rule and path compression#include "ufs.h" // without eitherusing namespace std; // for string declaration and cout// ------------------------- Global variables -----------------------int rseed; // random number seed, argv[1]int rowsize; // number of maze rows, argv[2]int colsize; // number of maze columns, argv[3]int rand1; // array index of random nodeint rand2; // array index of random neighborint temp; // for switching rand1, rand2 orderint temp2;int nsew; // north, south, east, westlong loopcount; // for testingint colcount; // for testingint findcalls; // number of calls to FINDint treetraversals;...
View Full Document

Page1 / 6

Prog04a -...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online