Module: Morphogen
- Defined in:
- lib/morphogen.rb
Overview
module Morphogen
Class Attribute Summary collapse
-
.classes ⇒ Array<Class>
readonly
An array of the classes that have included this module.
Instance Attribute Summary collapse
-
#char ⇒ Object
readonly
Returns the value of attribute char.
Class Method Summary collapse
Instance Method Summary collapse
-
#color ⇒ String
You should overwrite this method.
-
#initialize(char:) ⇒ Object
Don't overwrite this method.
-
#moves(world_state) ⇒ Array<Integer>
You should overwrite this method.
-
#name ⇒ String
You can overwrite this method.
-
#seed ⇒ Array<String>
You should overwrite this method.
Class Attribute Details
.classes ⇒ Array<Class> (readonly)
An array of the classes that have included this module
8 9 10 |
# File 'lib/morphogen.rb', line 8 def classes @classes end |
Instance Attribute Details
#char ⇒ Object (readonly)
Returns the value of attribute char
17 18 19 |
# File 'lib/morphogen.rb', line 17 def char @char end |
Class Method Details
.included(klass) ⇒ Object
11 12 13 14 |
# File 'lib/morphogen.rb', line 11 def included(klass) @classes ||= [] @classes << klass end |
Instance Method Details
#color ⇒ String
You should overwrite this method. A hex color string used to represent this class.
37 38 39 |
# File 'lib/morphogen.rb', line 37 def color @color ||= '#' + %w[0 3 6 9 C F].shuffle.join end |
#initialize(char:) ⇒ Object
Don't overwrite this method. The character assigned to this class by the game and how the world will represent this class in the game
23 24 25 |
# File 'lib/morphogen.rb', line 23 def initialize(char:) @char = char end |
#moves(world_state) ⇒ Array<Integer>
You should overwrite this method. Given a current world state, return the two (empty) positions you'd like to make as moves.
62 63 64 |
# File 'lib/morphogen.rb', line 62 def moves(world_state) [] end |
#name ⇒ String
You can overwrite this method. The name used to represent this class.
30 31 32 |
# File 'lib/morphogen.rb', line 30 def name self.class.to_s end |
#seed ⇒ Array<String>
You should overwrite this method. This is your starting pattern in the game
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/morphogen.rb', line 44 def seed [ 'X X X X ', ' X X X X', 'X X X X ', ' X X X X', 'X X X X ', ' X X X X', 'X X X X ', ' X X X X', ] end |