Module: TreeRemoveNodeMutator
- Defined in:
- lib/charlie/tree/tree.rb
Overview
replaces a random node by one of its children. does nothing if the randomly chosen node is a terminal.
Instance Method Summary collapse
Instance Method Details
#mutate! ⇒ Object
225 226 227 228 229 230 |
# File 'lib/charlie/tree/tree.rb', line 225 def mutate! st = random_subtree return self if st.first==:term st.replace st[1..-1].at_rand self end |