@@ -30,6 +30,9 @@ const TILE_SHAPES = {
3030 'null4' : [ 1 , 3 ] ,
3131} ;
3232
33+ // Chance of showing a random wall tile other than the default.
34+ const RANDOM_TILE_RATE = 0.2 ;
35+
3336module . exports = class Subtype extends EventEmitter {
3437 constructor ( maze , { skin, level} = { } ) {
3538 super ( ) ;
@@ -136,10 +139,10 @@ module.exports = class Subtype extends EventEmitter {
136139 ) ;
137140 }
138141
139- getEmptyTile ( x , y , adjacentToPath ) {
142+ getEmptyTile ( x , y , adjacentToPath , innerCorner ) {
140143 let tile ;
141144 // Empty square. Use null0 for large areas, with null1-4 for borders.
142- if ( ! adjacentToPath && Math . random ( ) > 0.3 ) {
145+ if ( innerCorner || ( ! adjacentToPath && Math . random ( ) > RANDOM_TILE_RATE ) ) {
143146 this . wallMap [ y ] [ x ] = 0 ;
144147 tile = 'null0' ;
145148 } else {
@@ -166,12 +169,14 @@ module.exports = class Subtype extends EventEmitter {
166169 this . isOnPathStr_ ( col , row + 1 ) + // South.
167170 this . isOnPathStr_ ( col - 1 , row ) ; // East.
168171
169- const adjacentToPath = ( tile !== '00000' ) ;
170-
171172 // Draw the tile.
172173 if ( ! TILE_SHAPES [ tile ] ) {
174+ const adjacentToPath = tile !== '00000' ;
175+ // Any block with 2, 3 or 4 orthogonal paths.
176+ const innerCorner = adjacentToPath && tile . split ( '1' ) . length > 2 ;
177+
173178 // We have an empty square. Handle it differently based on skin.
174- tile = this . getEmptyTile ( col , row , adjacentToPath ) ;
179+ tile = this . getEmptyTile ( col , row , adjacentToPath , innerCorner ) ;
175180 }
176181
177182 this . drawTile ( svg , TILE_SHAPES [ tile ] , row , col , tileId ) ;
0 commit comments