Restructure Rules #20

Open
opened 2018-07-10 12:51:46 +00:00 by marty-oehme · 3 comments
marty-oehme commented 2018-07-10 12:51:46 +00:00 (Migrated from gitlab.com)

Currently rules are only an evaluation function. This means unnecessary overhead when iterating through the grid of cells later. (iterate surviveRules, iterate birthRules) It also is not expandable to new effects (death effect, multiplication effect etc)

Therefore Rules should be buildable (through e.g. json input) to have an effect, an evaluation function and type of evaluation input (currently only neighbor count, could be history etc). Only effects should be necessary, the other two should have default implementations.

example implementation:

enum RuleEffect { Birth, Survival }
enum RuleInput { Neighbors }

class Rule {
  final Function evaluate;
  final RuleEffect effect;

  Rule(RuleEffect effect, {Function evaluate, RuleInput input, int desiredValue})
      : this.effect = effect,
        this.input = input ?? RuleInput.Neighbors,
        this.evaluate = evaluate ?? ((int input) { input == desiredValue ?? 0; }) {}
}

Currently rules are only an evaluation function. This means unnecessary overhead when iterating through the grid of cells later. (iterate surviveRules, iterate birthRules) It also is not expandable to new effects (death effect, multiplication effect etc) Therefore Rules should be buildable (through e.g. json input) to have an effect, an evaluation function and type of evaluation input (currently only neighbor count, could be history etc). Only effects should be necessary, the other two should have default implementations. example implementation: ``` dart enum RuleEffect { Birth, Survival } enum RuleInput { Neighbors } class Rule { final Function evaluate; final RuleEffect effect; Rule(RuleEffect effect, {Function evaluate, RuleInput input, int desiredValue}) : this.effect = effect, this.input = input ?? RuleInput.Neighbors, this.evaluate = evaluate ?? ((int input) { input == desiredValue ?? 0; }) {} } ```
marty-oehme commented 2018-07-10 12:52:42 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
marty-oehme commented 2018-08-31 07:28:22 +00:00 (Migrated from gitlab.com)

added ~7009327 and removed ~7009326 labels

added ~7009327 and removed ~7009326 labels
marty-oehme commented 2018-10-25 15:37:44 +00:00 (Migrated from gitlab.com)

changed milestone to %4

changed milestone to %4
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: experiments/cellular-automata#20
No description provided.