我在这里遵循本指南:http: //www.mazeworks.com/mazegen/mazetut/index.htm
或者更具体地
create a CellStack (LIFO) to hold a list of cell locations set TotalCells = number of cells in grid choose a cell at random 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 endIf endWhile
我用java写这个,我的问题是。
我应该如何存储我访问过的单元格,以便我可以从放置它们时的相反顺序访问它们。
像这样?
List<Location> visitedCells = new ArrayList<Location>();
Then do I grab with visitedCells.get(visitedCells.size()-1)?
位置存储 x、y 和 z。不是我想问你的。