Crossingover test done, display test rework
This commit is contained in:
parent
f1633ee8d5
commit
32af1e0be7
1 changed files with 44 additions and 3 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
use crate::genetics::{flow::Flow, gene::{Gene, GeneType,GeneSource}, genome::Genome, manipulations::PairGenomeModificator, plant_templates::{peashooter_template, sunflower_template}};
|
use crate::genetics::{flow::Flow, gene::{Gene, GeneSource, GeneType}, genome::Genome, manipulations::PairGenomeModificator, plant_templates::{cherry_bomb_template, peashooter_template, sunflower_template}};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_display() {
|
fn test_display() {
|
||||||
println!("{}",peashooter_template());
|
let display_target = cherry_bomb_template();
|
||||||
assert!(peashooter_template().to_string() == "(Peashooter) root\n\t(Peashooter) stem\n\t\t(Peashooter) head\n\t\t\t(Peashooter) leaf\n\t\t\t(Peashooter) face\n");
|
println!("{}",display_target);
|
||||||
|
assert!(display_target.to_string() == "(CherryBomb) root\n\t(CherryBomb) head\n\t\t(CherryBomb) face\n\t(CherryBomb) head\n\t\t(CherryBomb) face\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -43,3 +44,43 @@ fn test_allelic_crossingover() {
|
||||||
(2,3),
|
(2,3),
|
||||||
]).unwrap().to_string());
|
]).unwrap().to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_categoric_crossingover() {
|
||||||
|
let mut peashooter = peashooter_template();
|
||||||
|
let mut cherry = cherry_bomb_template();
|
||||||
|
|
||||||
|
println!("Peashooter\n{}",peashooter);
|
||||||
|
println!("CherryBomb\n{}",cherry);
|
||||||
|
|
||||||
|
(peashooter,cherry) = PairGenomeModificator::with_seed(peashooter, cherry,3996684975687038250u64).categoric_crossingover(None);
|
||||||
|
|
||||||
|
println!("Peashooter:\n{}",peashooter);
|
||||||
|
println!("CherryBomb:\n{}",cherry);
|
||||||
|
|
||||||
|
assert!(peashooter.to_string() == Genome::from_edges(vec![
|
||||||
|
Gene::new(GeneSource::CherryBomb,"root", GeneType::modifier(|_|{Flow::empty()})),
|
||||||
|
Gene::new(GeneSource::Peashooter,"stem", GeneType::fill_all()),
|
||||||
|
Gene::new(GeneSource::CherryBomb,"head", GeneType::consumer(|_|{})),
|
||||||
|
Gene::new(GeneSource::Peashooter,"leaf",GeneType::modifier(|_|{Flow::empty()})),
|
||||||
|
Gene::new(GeneSource::CherryBomb,"face", GeneType::Dummy),
|
||||||
|
],vec![
|
||||||
|
(0,1),
|
||||||
|
(1,2),
|
||||||
|
(2,3),
|
||||||
|
(2,4)
|
||||||
|
]).unwrap().to_string());
|
||||||
|
|
||||||
|
assert!(cherry.to_string() == Genome::from_edges(vec![
|
||||||
|
Gene::new(GeneSource::Peashooter,"root", GeneType::pure_producer(|_|{Flow::empty()})),
|
||||||
|
Gene::new(GeneSource::CherryBomb,"head", GeneType::consumer(|_|{})),
|
||||||
|
Gene::new(GeneSource::Peashooter,"head",GeneType::random_distribution()),
|
||||||
|
Gene::new(GeneSource::CherryBomb,"face", GeneType::Dummy),
|
||||||
|
Gene::new(GeneSource::Peashooter,"face",GeneType::consumer(|_|{})),
|
||||||
|
], vec![
|
||||||
|
(0,1),
|
||||||
|
(0,2),
|
||||||
|
(1,3),
|
||||||
|
(2,4),
|
||||||
|
]).unwrap().to_string());
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue