January 2019
Intermediate to advanced
236 pages
5h 41m
English
Each of your CAs will use a Row of 32 cells:
| | typedef std::array<bool, 32> Row; |
The array has a fixed size. You can use a vector, as you did in the previous chapter, if you want to dynamically change the row size. You’ll need to experiment with the parameters for your GA if you change this.
Each CA works via a rule acting on a Row. If you make an abstract Rule, you’ll be able to polymorphically swap your CA for use in the same genetic algorithm. To do this, use a virtual operator() to transform a Row:
| | class Rule |
| | { |
| | public: |
| | virtual Row operator()(const Row & cells) const = 0; |
| | }; |
To make a concrete rule, you override the virtual function. Your first CA will use a StaticRule ...
Read now
Unlock full access