From 6d7120650fdb2ab2757cb8052bc18cd481cdf3db Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 17 Oct 2018 21:08:55 +0200 Subject: [PATCH] Add Special Patterns to RuleSet --- lib/src/RuleSet.dart | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/src/RuleSet.dart b/lib/src/RuleSet.dart index edfc5a9..f115699 100644 --- a/lib/src/RuleSet.dart +++ b/lib/src/RuleSet.dart @@ -4,6 +4,7 @@ import 'package:collection/collection.dart'; abstract class RuleSet { int checkRange; + List patterns; bool checkSurvival(int neighbors); bool checkBirth(int neighbors); @@ -20,6 +21,32 @@ class Pattern extends DelegatingList { class GameOfLife implements RuleSet { int checkRange = 1; + List patterns = [ + // Two blocks, offset + // ## + // ## + Pattern("Blinker", [ + Point(0, 0), + Point(1, 0), + Point(0, 1), + Point(1, 1), + Point(2, 2), + Point(3, 2), + Point(2, 3), + Point(3, 3) + ]), + // A 'gliding' Spaceship + // # + // # + // ### + Pattern("SpaceShip", [ + Point(1, 0), + Point(2, 1), + Point(2, 2), + Point(1, 2), + Point(0, 2), + ]) + ]; bool checkSurvival(int neighbors) => neighbors == 2 || neighbors == 3 ? true : false;