Refactor Directories
Move Engine Files to /src Directory
This commit is contained in:
parent
f3dfc3b368
commit
827ab83b88
4 changed files with 5 additions and 5 deletions
27
lib/src/Cell.dart
Normal file
27
lib/src/Cell.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:rules_of_living/src/Rule.dart';
|
||||
|
||||
class Cell {
|
||||
bool state;
|
||||
bool nextState = false;
|
||||
List<Rule> surviveRules = new List<Rule>();
|
||||
List<Rule> birthRules = new List<Rule>();
|
||||
|
||||
Cell([bool state = false]) : this.state = state;
|
||||
|
||||
void advanceState() {
|
||||
this.state = this.nextState;
|
||||
this.nextState = false;
|
||||
}
|
||||
|
||||
void update(int neighbors) {
|
||||
if (state == true) {
|
||||
surviveRules.forEach( (Rule rule) {
|
||||
if(rule.evaluate(neighbors) == true) this.nextState = true;
|
||||
});
|
||||
} else {
|
||||
birthRules.forEach((Rule rule) {
|
||||
if (rule.evaluate(neighbors) == true) this.nextState = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue