UNPKG

ts-hashlife

Version:

Efficient TypeScript implementation of HashLife, an optimized algorithm for simulating Conway's Game of Life with memoization and quadtree-based compression.

35 lines (34 loc) 1.51 kB
import { LifeUniverse, TreeNode } from "./life-universe"; import { LifeCanvasDrawer } from "./draw"; import { Result, Pattern } from "./formats"; import { load_macrocell } from "./macrocell"; import EventBus, { EventMap } from "./event-bus"; import Game from "./hash-life"; declare const HashLife: { EventBus: { "__#1@#listeners": { [key: string]: ((data: any) => void)[]; }; emit<K extends keyof EventMap>(event: K, data: EventMap[K]): void; on<K extends keyof EventMap>(event: K, callback: (data: EventMap[K]) => void): () => void; off<K extends keyof EventMap>(event: K, callback: (data: EventMap[K]) => void): void; clear<K extends keyof EventMap>(event?: K): void; }; Game: typeof Game; LifeUniverse: typeof LifeUniverse; TreeNode: typeof TreeNode; LifeCanvasDrawer: typeof LifeCanvasDrawer; formats: { parse_rle: (pattern_string: string) => Result; parse_pattern: (pattern_text: string) => Partial<Result> | { error: string; }; rule2str: (rule_s: number, rule_b: number) => string; parse_rule: (rule_str: string, survived: boolean) => number; parse_comments: (pattern_string: string, comment_char: string) => Result; generate_rle: (life: any, name: string, comments: string[]) => string; }; load_macrocell: typeof load_macrocell; }; export { EventBus, Game as HashLife, type Result, type Pattern, type EventMap, }; export default HashLife;