Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PROGRAMMING Take a 2D String Array containing a grid and turn it into a maze using the following Psuedocode : create a CellStack (LIFO)

JAVA PROGRAMMING Take a 2D String Array containing a "grid" and turn it into a maze using the following Psuedocode: 

create a CellStack (LIFO) to hold a list of cell locations set TotalCells= number of cells in grid choose the starting cell and call it CurrentCell set VisitedCells = 1 while VisitedCells < TotalCells find all neighbors of CurrentCell with all walls intact if one or more found choose one at random knock down the wall between it and CurrentCell push CurrentCell location on the CellStack make the new cell CurrentCell add 1 to VisitedCells else pop the most recent cell entry off the CellStack make it CurrentCell

//--------------------------------------------------------

Code for blank grid:

int row; int column; int cell; String[][] grid;
public void createGrid(){ for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[i].length; j++) { if (j % 2 == 1) { grid[i][j] = "-"; } else if (i % 2 == 1) { grid[i][j] = "|"; } else { grid[i][j] = "+"; } if (i % 2 == 1 && j % 2 == 1) { grid[i][j] = " "; } } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

LO5 Highlight five external recruiting sources.

Answered: 1 week ago