Dynamic genome building

This commit is contained in:
Rendo 2026-03-28 20:21:12 +05:00
commit a9615c07a7
5 changed files with 94 additions and 12 deletions

View file

@ -6,10 +6,24 @@ pub struct Gene {
#[derive(PartialEq,Eq,Clone)]
pub enum GeneType {
Producer,
Transport,
Consumer,
Modifier,
PureProducer {
create_flow: fn()
},
Transport {
distribute_between_children: fn()
},
Consumer {
consume: fn()
},
Modifier {
modify_flow: fn()
},
Trigger {
check_trigger: fn()
},
Observer {
observe: fn()
},
}
impl Gene {
@ -20,3 +34,27 @@ impl Gene {
}
}
}
impl GeneType {
pub fn pure_producer(flow_function: fn()) -> Self {
Self::PureProducer { create_flow: flow_function }
}
pub fn random_distribution() -> Self {
Self::Transport { distribute_between_children: ||{} }
}
pub fn fill_all() -> Self {
Self::Transport { distribute_between_children: ||{} }
}
pub fn consumer(consumer_function: fn()) -> Self {
Self::Consumer { consume: consumer_function }
}
pub fn modifier(modifier_function: fn()) -> Self {
Self::Modifier { modify_flow: modifier_function }
}
pub fn trigger(trigger_function: fn()) -> Self {
Self::Trigger { check_trigger: trigger_function }
}
pub fn observer(observer_function: fn()) -> Self {
Self::Observer { observe: observer_function }
}
}