diff --git a/radiate-gp/src/collections/builder.rs b/radiate-gp/src/collections/builder.rs index 196dd7e..9507dc0 100644 --- a/radiate-gp/src/collections/builder.rs +++ b/radiate-gp/src/collections/builder.rs @@ -3,8 +3,8 @@ /// This is a quality of life trait to help with the builder pattern or /// with things that can be 'built'. There are a multitude of things in /// the `radiate_gp` crate that rely on being 'built', and this trait is -/// meant to abstract that out. For example, the `Tree`, `Graph', `TreeChromosome`, -/// `GraphChromosome` can all be 'built' and thus implement this trait. +/// meant to abstract that out. For example, the `Tree` and `Graph', +/// can all be 'built' and thus implement this trait. /// /// # Example building a `Tree>`: /// ```rust @@ -22,6 +22,18 @@ /// assert!(tree.height() == 3); /// assert!(tree.size() == 15); /// ``` +/// +/// The above will result in a tree that looks something like: +/// ```text +/// + +/// / \ +/// + * +/// / \ / \ +/// 1 2 1 2 +/// ``` +/// **Note**: The above is not guaranteed, but is a good example of what +/// the tree will look like. It isn't guaranteed because the `TreeBuilder` +/// uses a random number generator to pick the value for each node. pub trait Builder { type Output; fn build(&self) -> Self::Output; diff --git a/radiate-gp/src/collections/trees/codex.rs b/radiate-gp/src/collections/trees/codex.rs index cb62269..2cdfd4c 100644 --- a/radiate-gp/src/collections/trees/codex.rs +++ b/radiate-gp/src/collections/trees/codex.rs @@ -42,7 +42,7 @@ where C: Clone + PartialEq + Default + NodeCell, { fn encode(&self) -> Genotype> { - let root = self.builder.build().root().take().unwrap().to_owned(); + let root = self.builder.build().take_root().unwrap(); if let Some(constraint) = &self.constraint { if !constraint(&root) {