1
Crear el guión del laberinto de apertura :
Maze clase pública { private int N; private boolean [ ] [ ] norte; private boolean [ ] [ ] este; private boolean [ ,"] [ ] al sur ; private boolean [ ] [ ] al oeste ; private boolean [ ] [ ] visitó ; tamaño doble privada ; private boolean hace = false;
Maze público ( int n ) { this.N = N; StdDraw.setXscale ( 0 , N 2 ) ; StdDraw.setYscale ( 0 , N 2 ), init (); generate ( ) ;}
2
Establecer un mecanismo de seguridad que impide que el programa de revisitar células : private void init () {//inicializar células fronterizas como ya visitedvisited = new Boolean [ N 2 ] [N 2 ] ; for (int x = 0 ; x < N 2 ; x + + ) visitó [x ] [ 0 ] = visitado [x ] [N +1] = true; for (int y = 0 , y < N 2 , y + + ) visitó [ 0 ] [ y] = visitados [N +1] [ y] = cierto,
3
Establecer todas las células en el laberinto como estar presente ://inicializar todas las células como presentnorth = new Boolean [ N 2 ] [N 2 ] , al este = new Boolean [N 2 ] [N 2 ] , al sur = new Boolean [ N 2 ] [N 2 ] , al oeste = new Boolean [ N 2 ] [N 2 ] ; for (int x = 0 ; x < , N 2 , x + +) for (int y = 0 , y < N 2 , y + + ) al norte [x ] [ y] = este [x ] [ y] = sur [x ] [ y] = oeste [x ] [ y] = true;}
4
Incluir laberinto líneas de generación de código: private void generar (int x , int y) { visitado [x ] [ y] = true;
< p> while ( visitado [x ] [y +1]