Add Tests to Simulation
This commit is contained in:
parent
e8c1e6ed8b
commit
2169de16fd
2 changed files with 48 additions and 10 deletions
|
|
@ -13,15 +13,15 @@ class Simulation {
|
|||
RuleSet rules = GameOfLife();
|
||||
|
||||
bool _dirty = true;
|
||||
bool get dirty => _dirty;
|
||||
|
||||
bool _renderEdges = true;
|
||||
bool get renderEdges => _renderEdges;
|
||||
|
||||
int _amount;
|
||||
int _dispersal;
|
||||
|
||||
int get w => map.width;
|
||||
int get h => map.height;
|
||||
|
||||
Point get gridSize => Point<int>(w, h);
|
||||
Point get gridSize => Point<int>(map.width, map.height);
|
||||
void set gridSize(Point<int> value) {
|
||||
if (value.x <= 0 || value.y <= 0)
|
||||
throw ArgumentError("grid size must not be smaller than 1");
|
||||
|
|
@ -29,13 +29,16 @@ class Simulation {
|
|||
}
|
||||
|
||||
Simulation(int w, int h) : this.map = new Grid(w, h) {
|
||||
reset();
|
||||
print("Grid Created");
|
||||
this.map = reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
map.setAll(0, List.filled(map.length, false));
|
||||
Simulation.fromGrid(Grid<bool> map) : this.map = map;
|
||||
|
||||
Grid<bool> reset([Grid<bool> map]) {
|
||||
map ??= this.map;
|
||||
_dirty = true;
|
||||
map.setAll(0, List.filled(map.length, false));
|
||||
return map;
|
||||
}
|
||||
|
||||
void addRandomPattern({int amount, int dispersal}) {
|
||||
|
|
@ -148,6 +151,4 @@ class Simulation {
|
|||
_renderEdges = on;
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
bool get renderEdges => _renderEdges;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue