Back to all Bounties
Earn 3,111 ($31.11)
due 1 month ago
Open
Rust implementation of Particle Lenia for WasmEdge
bmorphism
Bounty Description
Problem Description
Use Rust to implement Particle Lenia in a way that can be compiled to run on WasmEdge (https://wasmedge.org/book/en/)
Use the guidelines and the type of memory use optimization from a similar Game of Life implementation below.
Submit a compiled .wasm binary together with the codebase, and briefly talk about steps you took to make the implementation energy-efficient.
Needs to be visualized using CanvasRenderingContext2D:
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
Code to implement:
https://google-research.github.io/self-organising-systems/particle-lenia/
https://colab.research.google.com/drive/14nw3aK5aOMH_brKYdRsXHKt0OgK1RteK?usp=sharing
Acceptance Criteria
Compiles, and has tests.
Appendix - Game of Life example
use std::thread; use std::time::Duration; const ROWS: usize = 30; const COLS: usize = 60; fn main() { let mut current_generation = vec![vec![false; COLS]; ROWS]; let mut next_generation = vec![vec![false; COLS]; ROWS]; // Initialize the current generation // ... loop { // Calculate the next generation for i in 0..ROWS { for j in 0..COLS { let mut live_neighbors = 0; for ii in i.saturating_sub(1)..=i.saturating_add(1) { for jj in j.saturating_sub(1)..=j.saturating_add(1) { if ii == i && jj == j { continue; } if ii < ROWS && jj < COLS && current_generation[ii][jj] { live_neighbors += 1; } } } next_generation[i][j] = if current_generation[i][j] { live_neighbors == 2 || live_neighbors == 3 } else { live_neighbors == 3 }; } } // Swap the current and next generations current_generation = next_generation; next_generation = vec![vec![false; COLS]; ROWS]; // Display the current generation // ... // Sleep for a short duration to slow down the simulation thread::sleep(Duration::from_millis(100)); } }