rust/landgen/src/wavefront_collapse/generator.rs
branchtransitional_engine
changeset 15919 659c92124c26
parent 15918 9bd828451d77
child 15920 168f44ef9b67
equal deleted inserted replaced
15918:9bd828451d77 15919:659c92124c26
   134 
   134 
   135         let grid = wfc.grid();
   135         let grid = wfc.grid();
   136 
   136 
   137         for r in 0..grid.height() {
   137         for r in 0..grid.height() {
   138             for c in 0..grid.width() {
   138             for c in 0..grid.width() {
   139                 print!("{:?}", grid.get(r, c));
   139                 print!("{:?} ", grid.get(r, c));
   140             }
   140             }
   141 
   141 
   142             println!();
   142             println!();
   143         }
   143         }
   144 
   144 
   181 
   181 
   182     #[test]
   182     #[test]
   183     fn test_generation() {
   183     fn test_generation() {
   184         let wfc_gen = WavefrontCollapseLandGenerator::new(&Size::new(2048, 1024));
   184         let wfc_gen = WavefrontCollapseLandGenerator::new(&Size::new(2048, 1024));
   185         let landgen_params = LandGenerationParameters::new(0u32, 0xff000000u32, 0, true, true);
   185         let landgen_params = LandGenerationParameters::new(0u32, 0xff000000u32, 0, true, true);
   186         let land = wfc_gen.generate_land(&landgen_params, &mut std::iter::repeat(0u32));
   186         let land = wfc_gen.generate_land(&landgen_params, &mut [0u32, 1u32, 3u32, 5u32, 7u32, 11u32].into_iter().cycle());
   187 
   187 
   188         let path = Path::new(r"output.png");
   188         let path = Path::new(r"output.png");
   189         let file = File::create(path).unwrap();
   189         let file = File::create(path).unwrap();
   190         let ref mut w = BufWriter::new(file);
   190         let ref mut w = BufWriter::new(file);
   191 
   191