@@ -16,8 +16,8 @@ export enum DeltaType {
1616export const worldContext = createContext < World > ( "world" ) ;
1717
1818export class World {
19- private _birthSet ! : Set < number > ;
20- private _survivalSet ! : Set < number > ;
19+ private _birthTable : boolean [ ] ;
20+ private _survivalTable : boolean [ ] ;
2121
2222 private _neighborCountsStartState = new Map < number , number > ( ) ;
2323 private _cellsStartState = new Map < number , Cell > ( ) ;
@@ -44,7 +44,7 @@ export class World {
4444 @observable public accessor randomizeAverageDensity = 0.5 ;
4545
4646 constructor ( ) {
47- [ this . _birthSet , this . _survivalSet ] = parseRule ( this . rule ) ;
47+ [ this . _birthTable , this . _survivalTable ] = parseRule ( this . rule ) ;
4848
4949 this . setRule = this . setRule . bind ( this ) ;
5050 this . setRandomizeFieldSize = this . setRandomizeFieldSize . bind ( this ) ;
@@ -91,7 +91,7 @@ export class World {
9191
9292 @action
9393 public setRule ( rule : Rule ) : void {
94- [ this . _birthSet , this . _survivalSet ] = parseRule ( rule ) ;
94+ [ this . _birthTable , this . _survivalTable ] = parseRule ( rule ) ;
9595
9696 this . rule = rule ;
9797
@@ -177,14 +177,14 @@ export class World {
177177 for ( const [ hash , cell ] of this . _cells ) {
178178 const neighborCount = this . _neighborCounts . get ( hash ) ;
179179
180- if ( ! neighborCount || ! this . _survivalSet . has ( neighborCount ) ) {
180+ if ( ! neighborCount || ! this . _survivalTable [ neighborCount ] ) {
181181 cellsToKill . add ( cell ) ;
182182 }
183183 }
184184
185185 // Mark cells to spawn
186186 for ( const [ hash , count ] of this . _neighborCounts ) {
187- if ( this . _birthSet . has ( count ) && ! this . _cells . has ( hash ) ) {
187+ if ( this . _birthTable [ count ] && ! this . _cells . has ( hash ) ) {
188188 const cell = Cell . fromHash ( hash ) ;
189189 cellsToSpawn . add ( cell ) ;
190190 }
0 commit comments