/** Start carving a maze at the specified coordinates. */
Start carving a maze at the specified coordinates.
/ ** Start carving a maze at the specified coordinates . * /
func CarveMaze(m *Maze, r *rand.Rand, x int, y int) {
   directions := [][]int { {1, 0}, {-1, 0}, {0, 1}, {0, -1} }
   d := r.Intn(4)
   m.data[y][x] = SPACE
   for i := 0; i < 4; i++ {
      dx, dy := directions[d][0], directions[d][1]
      ax, ay := x + dx, y + dy
      bx, by := ax + dx, ay + dy
      if m.data[ay][ax] == WALL && m.data[by][bx] == WALL {
         m.data[ay][ax] = SPACE
         CarveMaze(m, r, bx, by)
      }
      d = (d + 1) % 4
   }
}
func CarveMaze ( m * Maze , r * rand . Rand , x int , y int ) { directions := [ ] [ ] int { { 1 , 0 } , { - 1 , 0 } , { 0 , 1 } , { 0 , - 1 } } d := r . Intn ( 4 ) m . data [ y ] [ x ] = SPACE for i := 0 ; i < 4 ; i ++ { dx , dy := directions [ d ] [ 0 ] , directions [ d ] [ 1 ] ax , ay := x + dx , y + dy bx , by := ax + dx , ay + dy if m . data [ ay ] [ ax ] == WALL && m . data [ by ] [ bx ] == WALL { m . data [ ay ] [ ax ] = SPACE CarveMaze ( m , r , bx , by ) } d = ( d + 1 ) % 4 } }
Start carving a maze at the specified coordinates.
Start carving a maze at the specified coordinates .