pub struct FibonacciHydraState {
pub heads: Vec<HydraHead>,
pub max_depth: u32,
pub next_id: u32,
pub split_hp_ratio: f32,
pub total_damage_pool: f32,
}Expand description
State for the Fibonacci Hydra. Starts as 1. On death, splits into 2 at 61.8% original HP each. Max depth 5 (up to 32 instances). All share a damage pool.
Fields§
§heads: Vec<HydraHead>§max_depth: u32Maximum split depth.
next_id: u32Next head ID to assign.
split_hp_ratio: f32Golden ratio factor for child HP.
total_damage_pool: f32Total damage dealt to all heads (shared pool).
Implementations§
Source§impl FibonacciHydraState
impl FibonacciHydraState
pub fn new(base_hp: f32) -> Self
Sourcepub fn alive_count(&self) -> usize
pub fn alive_count(&self) -> usize
Count alive heads.
Sourcepub fn try_split(&mut self, dead_head_id: u32) -> Option<(u32, u32)>
pub fn try_split(&mut self, dead_head_id: u32) -> Option<(u32, u32)>
Split a dead head into two children. Returns new head IDs if split occurred.
Sourcepub fn damage_head(&mut self, head_id: u32, amount: f32) -> bool
pub fn damage_head(&mut self, head_id: u32, amount: f32) -> bool
Apply damage to a specific head. Returns true if it died.
Sourcepub fn is_defeated(&self) -> bool
pub fn is_defeated(&self) -> bool
Check if the hydra is fully defeated (no alive heads and no more splits possible).
Sourcepub fn max_possible_heads(&self) -> u32
pub fn max_possible_heads(&self) -> u32
Maximum possible heads at full depth.
Trait Implementations§
Source§impl Clone for FibonacciHydraState
impl Clone for FibonacciHydraState
Source§fn clone(&self) -> FibonacciHydraState
fn clone(&self) -> FibonacciHydraState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FibonacciHydraState
impl Debug for FibonacciHydraState
Auto Trait Implementations§
impl Freeze for FibonacciHydraState
impl RefUnwindSafe for FibonacciHydraState
impl Send for FibonacciHydraState
impl Sync for FibonacciHydraState
impl Unpin for FibonacciHydraState
impl UnsafeUnpin for FibonacciHydraState
impl UnwindSafe for FibonacciHydraState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.