subject

You will implement random maze generation. start by downloading the attached source file. study the starting code and make the following changes:
implement makemazerecursive(char[][]level, int startx, int starty, int endx, int endy) using the recursive division method. a general description is on wikipedia:
"mazes can be created with recursive division, an algorithm which works as follows: begin with the maze's space with no walls. call this a chamber. divide the chamber with a randomly positioned wall (or multiple walls) where each wall contains a randomly positioned passage opening within it. then recursively repeat the process on the subchambers until all chambers are minimum sized. this method results in mazes with long straight walls crossing their space, making it easier to see which areas to avoid.
for example, in a rectangular maze, build at random points two walls that are perpendicular to each other. these two walls divide the large chamber into four smaller chambers separated by four walls. choose three of the four walls at random, and open a one cell-wide hole at a random point in each of the three. continue in this manner recursively, until every chamber has a width of one cell in either of the two directions."
you will implement random maze generation. start b
this function is recursive. note: do not call it on a sub-area when that area is less than 3x3 - this will cause walls to double up.
since this algorithm does not use any data structures or back tracking, it can create mazes that are not solveable.
hints:
(the screen shots below use numbers for walls in order to indicate which call to makemazerecursive created them - you should use only a # in your final submission.)
it is not necessary to follow these hints, you may implement this algorithm as you see fit based on the description above.
consider creating a function called randbetween(int l, int u) that creates a random number in an interval - wouldn't this function be useful for deciding where walls should go?
as a first step, implement the basic functionality to draw the two walls that divide the area into four rooms; don't proceed (i. e. add recursion) until it works.
then implement the recursive call for just one of the sub-areas; don't proceed until it works.
then extend the code to the other sub-areas.
after you are done, rename the finalized code to "lastname_pp3.java" (e. g. "acuna_pp3.java"). remember to change the class name as well.
/**
* write a description of class base_pp3 here.
*
* @author (your name), acuna
* @version (a version number or a date)
*/
import java. util. random;
public class base_pp3
{
//standard console size in characters.
private static final int level_height = 25;
private static final int level_width = 80;
private static final char icon_wall = '#';
private static final char icon_blank = ' ';
/**
* returns a 2d array containing a statically created maze with dimentions 80x24.
*
* @return 2d array containing a maze
*/
private static char[][] makemazestatic()
{
//the following maze was generated with the recursive division method and then modified by hand.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 14:00, GGerardi7552
What are procedures that keep a data base current
Answers: 1
image
Computers and Technology, 23.06.2019 08:00, ionmjnm3041
The managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an .
Answers: 3
image
Computers and Technology, 23.06.2019 19:00, brittneyrenae7338
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words. size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words. size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
image
Computers and Technology, 24.06.2019 11:00, dirttrackr75
Which of the statements below describe the guidelines for the use of text in presentation programs? a. do not use numbered lists. b. fonts should be appropriate for your audience. c. limit the number of fonts you use to three or four. d. only use bulleted lists for sales promotions. e. select font sizes that are appropriate for your delivery method. f. use font colors that work well with your background. select all that apply
Answers: 1
You know the right answer?
You will implement random maze generation. start by downloading the attached source file. study the...

Questions in other subjects:

Konu
Social Studies, 15.11.2019 04:31
Konu
Social Studies, 15.11.2019 04:31