diff --git a/README.md b/README.md
index 242ce4e..b0f8f1d 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ The installation steps presume that the next software are installed on your mach
After cloning the repository and moving at the root of the folder, you can:
- Install dependencies with `npm i`.
-- Build the project with `npx nx build life_game` (nx will take care of the build dependency graph!).
+- Build the wasm projects with `npx nx run-many --target build --projects life_game,lenia` (nx will take care of the build dependency graph!).
- Run the angular app with `npx nx serve pwa`.
- Go to `http://localhost:4200`
diff --git a/apps/pwa/src/app/lenia/lenia.component.html b/apps/pwa/src/app/lenia/lenia.component.html
index 20acdb5..700ef60 100644
--- a/apps/pwa/src/app/lenia/lenia.component.html
+++ b/apps/pwa/src/app/lenia/lenia.component.html
@@ -34,9 +34,17 @@
-
+ >
FPS: {{ fps || 0 }}
diff --git a/apps/pwa/src/app/life-game/life-game-engine/life-game-engine.component.ts b/apps/pwa/src/app/life-game/life-game-engine/life-game-engine.component.ts
index 8943a17..4a80223 100644
--- a/apps/pwa/src/app/life-game/life-game-engine/life-game-engine.component.ts
+++ b/apps/pwa/src/app/life-game/life-game-engine/life-game-engine.component.ts
@@ -8,8 +8,8 @@ import {
import { CommonModule } from '@angular/common';
import { Cell, Universe } from '@ml/life_game';
import { memory } from '@ml/life_game/life_game_bg.wasm';
-import { LifeGameControlFormComponent } from '../life-game-control-form/life-game-control-form.component';
-import { LifeGamePlayMode } from '../life-game.types';
+import { SimulationControlFormComponent } from '../../simulation-control-form/simulation-control-form.component';
+import { SimulationPlayMode } from '../../simulation.types';
const CELL_SIZE = 5; // px
const GRID_COLOR = '#CCCCCC';
@@ -21,7 +21,7 @@ const ALIVE_COLOR = '#000000';
standalone: true,
templateUrl: './life-game-engine.component.html',
styleUrl: './life-game-engine.component.scss',
- imports: [CommonModule, LifeGameControlFormComponent],
+ imports: [CommonModule, SimulationControlFormComponent],
})
export class LifeGameEngineComponent implements AfterViewInit {
@Input()
@@ -95,7 +95,7 @@ export class LifeGameEngineComponent implements AfterViewInit {
*
* @param playMode - the play mode selected by the user
*/
- updatePlayMode(playMode: LifeGamePlayMode) {
+ updatePlayMode(playMode: SimulationPlayMode) {
switch (playMode) {
case 'play':
this.play();
diff --git a/apps/pwa/src/app/life-game/life-game.types.ts b/apps/pwa/src/app/life-game/life-game.types.ts
index afac17c..df8cd9a 100644
--- a/apps/pwa/src/app/life-game/life-game.types.ts
+++ b/apps/pwa/src/app/life-game/life-game.types.ts
@@ -1,9 +1,3 @@
-export type LifeGamePlayMode = 'play' | 'pause';
-
-export interface LifeGameControl {
- playMode: LifeGamePlayMode;
-}
-
export interface LifeGameConfig {
width: number;
height: number;
diff --git a/apps/pwa/src/app/life-game/life-game-control-form/life-game-control-form.component.html b/apps/pwa/src/app/simulation-control-form/simulation-control-form.component.html
similarity index 100%
rename from apps/pwa/src/app/life-game/life-game-control-form/life-game-control-form.component.html
rename to apps/pwa/src/app/simulation-control-form/simulation-control-form.component.html
diff --git a/apps/pwa/src/app/life-game/life-game-control-form/life-game-control-form.component.scss b/apps/pwa/src/app/simulation-control-form/simulation-control-form.component.scss
similarity index 100%
rename from apps/pwa/src/app/life-game/life-game-control-form/life-game-control-form.component.scss
rename to apps/pwa/src/app/simulation-control-form/simulation-control-form.component.scss
diff --git a/apps/pwa/src/app/life-game/life-game-control-form/life-game-control-form.component.ts b/apps/pwa/src/app/simulation-control-form/simulation-control-form.component.ts
similarity index 65%
rename from apps/pwa/src/app/life-game/life-game-control-form/life-game-control-form.component.ts
rename to apps/pwa/src/app/simulation-control-form/simulation-control-form.component.ts
index bf9099d..911637f 100644
--- a/apps/pwa/src/app/life-game/life-game-control-form/life-game-control-form.component.ts
+++ b/apps/pwa/src/app/simulation-control-form/simulation-control-form.component.ts
@@ -5,11 +5,11 @@ import { MatFormFieldModule, MatLabel } from '@angular/material/form-field';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatButtonModule } from '@angular/material/button';
import { MatInputModule } from '@angular/material/input';
-import { LifeGamePlayMode } from '../life-game.types';
import { MatIcon } from '@angular/material/icon';
+import { SimulationPlayMode } from '../simulation.types';
@Component({
- selector: 'ml-life-game-control-form',
+ selector: 'ml-simulation-control-form',
standalone: true,
imports: [
CommonModule,
@@ -22,19 +22,19 @@ import { MatIcon } from '@angular/material/icon';
MatLabel,
MatIcon,
],
- templateUrl: './life-game-control-form.component.html',
- styleUrl: './life-game-control-form.component.scss',
+ templateUrl: './simulation-control-form.component.html',
+ styleUrl: './simulation-control-form.component.scss',
})
-export class LifeGameControlFormComponent {
+export class SimulationControlFormComponent {
@Input()
- defaultPlayMode: LifeGamePlayMode = 'pause';
+ defaultPlayMode: SimulationPlayMode = 'pause';
@Output()
- playModeChange = new EventEmitter();
+ playModeChange = new EventEmitter();
@Output()
next = new EventEmitter();
- playModeControl = new FormControl(this.defaultPlayMode, {
+ playModeControl = new FormControl(this.defaultPlayMode, {
updateOn: 'change',
});
}
diff --git a/apps/pwa/src/app/simulation.types.ts b/apps/pwa/src/app/simulation.types.ts
new file mode 100644
index 0000000..c34744c
--- /dev/null
+++ b/apps/pwa/src/app/simulation.types.ts
@@ -0,0 +1,5 @@
+export type SimulationPlayMode = 'play' | 'pause';
+
+export interface SimulationControl {
+ playMode: SimulationPlayMode;
+}
diff --git a/libs/lenia/project.json b/libs/lenia/project.json
index af31046..f71fc85 100644
--- a/libs/lenia/project.json
+++ b/libs/lenia/project.json
@@ -9,7 +9,7 @@
"executor": "nx:run-commands",
"options": {
"commands": [
- "npx wasm-pack build libs/lenia --out-dir ../../dist/wasm/lenia --target bundler --release --scope ml",
+ "npx wasm-pack build libs/lenia --out-dir ../../dist/wasm/lenia --target bundler --scope ml",
"npm i dist/wasm/lenia"
],
"parallel": false,
diff --git a/libs/lenia/src/lib.rs b/libs/lenia/src/lib.rs
index e4d26e6..18f442e 100644
--- a/libs/lenia/src/lib.rs
+++ b/libs/lenia/src/lib.rs
@@ -75,6 +75,10 @@ impl Lenia {
pub fn convolution_kernel(&self) -> *const f64 {
self.convolution_kernel.m.as_ptr()
}
+
+ pub fn size(&self) -> usize {
+ self.size
+ }
}
impl Lenia {