#wave #collapse #function #rust

billow

Rust实现的简单波函数坍缩

2个不稳定版本

1.0.0 2022年9月2日
0.2.0 2022年9月2日
0.1.0 2022年9月2日

#1047游戏开发

GPL-3.0 许可证

2MB
446 代码行

Billow

Crates.io Billow documentation

Rust实现的波函数坍缩算法。基于Oskar StålbergMartin Donald的详细解释。

🚧 这是一个进行中的作品。

用法

这是一个通用库,我提供了对image::DynamicImagebevy::prelude::Image类型的实现。

use billow::Wave;
use image::DynamicImage;

fn main() {
    let input: Vec<DynamicImage> = load_assets("assets/basic");
    let (width, height) = (20usize, 20usize);

    // New wave with a 20x20 grid
    let mut wave = Wave::new(input, width, height);

    // Populate the grid and choose a random starting point
    wave.initialize()

    // Run the algorithm.
    // This will try to collapse the grid to a single state.
    // `100` is the number of iterations.
    // each iteration will collapse one cell and try to propagate the changes.
    wave.collapse(100).expect("Failed to collapse");
}

更多内容请参阅示例

依赖项

~13–30MB
~282K SLoC