Skip to content

Commit

Permalink
feat: read outer-totalistic rule
Browse files Browse the repository at this point in the history
  • Loading branch information
rei1024 committed Oct 14, 2024
1 parent cdd6c6c commit 0f44900
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
16 changes: 12 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"preview": "vite preview"
},
"devDependencies": {
"@ca-ts/algo": "npm:@jsr/ca-ts__algo@^0.2.0",
"@ca-ts/algo": "npm:@jsr/ca-ts__algo@^0.4.0",
"@ca-ts/rle": "npm:@jsr/ca-ts__rle@^0.8.0",
"@ca-ts/rule": "npm:@jsr/ca-ts__rule@^0.2.0",
"babylonjs": "^7.29.0",
"typescript": "^5.6.3",
"vite": "^5.4.1"
},
"dependencies": {}
}
}
7 changes: 7 additions & 0 deletions src/lib/setRLE.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import type { BitWorld } from "@ca-ts/algo/bit";
import { parseRLE } from "@ca-ts/rle";
import { parseRule } from "@ca-ts/rule";

export function setRLE(bitWorld: BitWorld, sourceRLE: string) {
const data = parseRLE(sourceRLE);

try {
bitWorld.setRule(parseRule(data.ruleString).transition);
} catch {
bitWorld.setRule({ birth: [3], survive: [2, 3] });
}

const width = data.size?.width ?? 0;
const height = data.size?.height ?? 0;

Expand Down

0 comments on commit 0f44900

Please sign in to comment.