Add js-sys crate to change initial Cell generation (50% random chance)
This commit is contained in:
parent
388e6d900f
commit
ef0c51d993
@ -18,6 +18,7 @@ wasm-bindgen = "0.2.100"
|
|||||||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
# code size when deploying.
|
# code size when deploying.
|
||||||
console_error_panic_hook = { version = "0.1.7", optional = true }
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
js-sys = "0.3.77"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
wasm-bindgen-test = "0.3.50"
|
wasm-bindgen-test = "0.3.50"
|
||||||
|
@ -92,8 +92,8 @@ impl Universe {
|
|||||||
let height = 64;
|
let height = 64;
|
||||||
|
|
||||||
let cells = (0..width * height)
|
let cells = (0..width * height)
|
||||||
.map(|i| {
|
.map(|_i| {
|
||||||
if i % 2 == 0 || i % 7 == 0 {
|
if js_sys::Math::random() < 0.5 {
|
||||||
Cell::Alive
|
Cell::Alive
|
||||||
} else {
|
} else {
|
||||||
Cell::Dead
|
Cell::Dead
|
||||||
|
Loading…
Reference in New Issue
Block a user