@@ -82,11 +82,11 @@ impl Settings {
8282
8383 let count = hallways. count ( ) ;
8484 let doors = if count > 0 {
85- self . generate_points ( & hallways, 40 / ( count as f64 ) . sqrt ( ) as u32 )
85+ self . generate_points ( & hallways, 40 / ( ( count as f64 ) . sqrt ( ) as u32 ) )
8686 } else {
8787 self . new_map ( )
8888 } ;
89- let points = self . generate_points ( & floor, 12 / ( ( self . size - 6 ) as f64 ) . sqrt ( ) as u32 ) ;
89+ let points = self . generate_points ( & floor, 12 / ( ( ( self . size - 6 ) as f64 ) . sqrt ( ) as u32 ) ) ;
9090
9191 ( layout, points, doors, 0 )
9292 }
@@ -98,8 +98,8 @@ impl Settings {
9898 count = 7 ;
9999 }
100100
101- let mut points = self . generate_points ( & cavern, 12 / ( ( count - 6 ) as f64 ) . sqrt ( ) as u32 ) ;
102- let doors = self . generate_points ( & cavern, 40 / ( count as f64 ) . sqrt ( ) as u32 ) ;
101+ let mut points = self . generate_points ( & cavern, 12 / ( ( ( count - 6 ) as f64 ) . sqrt ( ) as u32 ) ) ;
102+ let doors = self . generate_points ( & cavern, 40 / ( ( count as f64 ) . sqrt ( ) as u32 ) ) ;
103103
104104 points. subtract ( & doors) ;
105105
@@ -150,13 +150,13 @@ impl Settings {
150150 let mut hallways = self . new_map ( ) ;
151151
152152 if rooms. is_empty ( ) {
153- return self . new_map ( ) ;
153+ return hallways ;
154154 }
155155
156156 let mut pre_x = rooms[ 0 ] . x + rooms[ 0 ] . width / 2 ;
157157 let mut pre_y = rooms[ 0 ] . y + rooms[ 0 ] . height / 2 ;
158158
159- for i in 1 ..rooms. len ( ) - 1 {
159+ for i in 1 ..rooms. len ( ) {
160160 let cur_x = rooms[ i] . x + rooms[ i] . width / 2 ;
161161 let cur_y = rooms[ i] . y + rooms[ i] . height / 2 ;
162162
@@ -417,8 +417,8 @@ impl Map for Vec<Vec<u8>> {
417417
418418 fn count ( & self ) -> u32 {
419419 let mut count = 0 ;
420- for i in 0 ..self . len ( ) {
421- for j in 0 ..self [ i ] . len ( ) {
420+ for j in 0 ..self . len ( ) {
421+ for i in 0 ..self [ j ] . len ( ) {
422422 if self [ j] [ i] == 1 {
423423 count += 1 ;
424424 }
0 commit comments