# Need assistance with small piece of larger assignment writing a recursive division algorithm (Java). The assignment is t...

###### Question:

Need assistance with small piece of larger assignment writing a recursive division algorithm (Java).

The assignment is to write a recursive division algorithm to build a maze in a 2D array.

I have code that will randomly generate vertical and horizontal walls and randomly place doorways in the walls.

Requirements:

The maze should be broken into sub-regions on each recursive method call until the sub-region is no less than 3x3.

My recursive calls only seem to work on the top left sub-region of each call and I can't seem to get it to work on every sub-region in the entire maze board.

Outline of my code:

1) BASE CASE - If the width of sub region is less than 3 and height of a sub-region is less than 3 (smaller than 3x3), do not run recursive method again. {

(below code is inside base case if statement)

variable X = randomly select a x value for vertical wall in the range of left boundary to right boundary

variable Y = randomly select a y value for horizontal wall in range of top boundary to bottom boundary

for loop to build vertical wall

randomly place passage somewhere along vertical wall

for loop to build horizontal wall

randomly place passage on horizontal wall LEFT of vertical wall

randomly place passage on horizontal wall RIGHT of vertical wall

run recursive method

}

Thoughts:

Should one recursive method call go inside of the base case if statement, then another call outside of it? How can I ensure EVERY sub-region greater than 3x3 is being divided to the base case.

#### Similar Solved Questions

##### .CO Question 13 of 14 A Lewis structure with placeholder elements is shown below. If the...
.CO Question 13 of 14 A Lewis structure with placeholder elements is shown below. If the formal charge of the central atom is 0, choose the possible identities of the central atom. A) B or AI B) O, S, or Se C) F, CI, Br, or D) Por As = E) S or Se...
##### O GASES Calculating mole fraction in a gas mixture A 8.00 L tank at 19.8 °C...
O GASES Calculating mole fraction in a gas mixture A 8.00 L tank at 19.8 °C is filled with 11.0 g of chlorine pentafluoride gas and 7.97 g of boron trifluoride gas. You can assume both gases behave as ideal gases under these conditions. Calculate the mole fraction of each gas. Be sure each of yo...
##### A ball is selected from an box containing two black balls, numbered 1 and 2, and...
A ball is selected from an box containing two black balls, numbered 1 and 2, and two white balls, numbered 3 and 4. Let the events A, B, and Cbe defined as follows: A-b). (2, b)3. "black ball selected": B (2.b). (4,w)), "even-numbered ball selected": and (3, w). (4, w)). "number ...
##### Simplify? sin^2xcotx+cosx
Simplify? sin^2xcotx+cosx...
##### I need help with questions 11 & 12 please. D Question 11 1 pts A study...
I need help with questions 11 & 12 please. D Question 11 1 pts A study reports the following final notation: F(2, 37) = 9.00,p<.05; how many total participants were involved in the study? O 37 O 38 O 39 о 40 Question 12 1 pts A study reports the following final notation: F(2, 37) - 9.0...
##### To test whether it’s reasonable to assume equal variances, you could do an F test as in the...
A sample of 25 concession stand purchases at the October 22 matinee of Bride of Chucky showed a mean purchase of $5.29 with a standard deviation of$3.02. For theOctober 26 evening showing of the same movie, for a sample of 25 purchases the mean was $5.12 with a standard deviation of$1.98. The mean...
##### Use quadratic formula to solve equation 0=x^2+x-20
use quadratic formula to solve equation 0=x^2+x-20...
##### Please show easy to follow work, thanks a lot! Question 1 (1 point) d The motion...
Please show easy to follow work, thanks a lot! Question 1 (1 point) d The motion of a particle is defined by the relationx- at 3-bt 2+ct + d, where x and t are expressed in meters and seconds, respectively, and a - 2.00, b- 9.00, c 4.00 and d 6.00 are constants. Determine the acceleration of the par...
##### A ball with a mass of 4 kg  and velocity of 2 m/s collides with a second ball with a mass of 2 kg and velocity of - 4 m/s. If 20% of the kinetic energy is lost, what are the final velocities of the balls?
A ball with a mass of 4 kg  and velocity of 2 m/s collides with a second ball with a mass of 2 kg and velocity of - 4 m/s. If 20% of the kinetic energy is lost, what are the final velocities of the balls?...