pub struct LifeField { /* private fields */ }Expand description
The Game of Life field state.
Implementations§
Source§impl LifeField
impl LifeField
Sourcepub fn from_seed(prompt: &str, width: usize, height: usize) -> Self
pub fn from_seed(prompt: &str, width: usize, height: usize) -> Self
Create a new LifeField seeded from a prompt
Sourcepub fn ensure_size(&mut self, width: usize, height: usize)
pub fn ensure_size(&mut self, width: usize, height: usize)
Ensures the field has the specified dimensions, reseeding if changed.
§Arguments
width- Desired width in cellsheight- Desired height in cells
Sourcepub fn step(&mut self)
pub fn step(&mut self)
Advances the simulation by one generation using Conway’s rules.
Rules:
- Live cell with 2-3 neighbors survives
- Dead cell with 3 or 6 neighbors becomes alive (highlife variant for 6)
- All other cells die or stay dead
The new heatmap-based injection system monitors activity across zones and injects patterns when activity falls below target levels.
Sourcepub fn live_neighbor_count(&self, x: usize, y: usize) -> u8
pub fn live_neighbor_count(&self, x: usize, y: usize) -> u8
Sourcepub fn update_heatmap(&mut self, old_cells: &[bool])
pub fn update_heatmap(&mut self, old_cells: &[bool])
Update heatmap after a generation step heat = heat * decay + (changed ? 1.0 : 0.0)
Sourcepub fn update_zones(&mut self)
pub fn update_zones(&mut self)
Update zone statistics based on current state
Sourcepub fn decay_cooldowns(&mut self)
pub fn decay_cooldowns(&mut self)
Decrement all zone cooldowns by 1
Sourcepub fn choose_injection_zone(&mut self) -> Option<usize>
pub fn choose_injection_zone(&mut self) -> Option<usize>
Choose a zone for injection using weighted randomness Prefers cold zones near warm zones
Sourcepub fn maybe_inject(&mut self)
pub fn maybe_inject(&mut self)
Check if injection should happen and perform it
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Get the current generation counter
Sourcepub fn dimensions(&self) -> (usize, usize)
pub fn dimensions(&self) -> (usize, usize)
Get field dimensions
Sourcepub fn live_cells(&self) -> Vec<(usize, usize)>
pub fn live_cells(&self) -> Vec<(usize, usize)>
Get all live cell positions
Sourcepub fn live_cell_count(&self) -> usize
pub fn live_cell_count(&self) -> usize
Get the number of live cells
Sourcepub fn config(&self) -> &LifeConfig
pub fn config(&self) -> &LifeConfig
Get configuration
Source§impl LifeField
impl LifeField
Sourcepub fn render_lines(
&self,
char_width: usize,
char_height: usize,
) -> Vec<Line<'static>>
pub fn render_lines( &self, char_width: usize, char_height: usize, ) -> Vec<Line<'static>>
Renders the field as a vector of ratatui Lines using Braille characters.
Each Braille character represents a 2x4 block of cells, allowing for compact display of the life field.
§Arguments
char_width- Width in characters (each char is 2 cells wide)char_height- Height in characters (each char is 4 cells tall)
§Returns
Vector of Lines representing the rendered field
Sourcepub fn braille_char(&self, dot_x: usize, dot_y: usize) -> char
pub fn braille_char(&self, dot_x: usize, dot_y: usize) -> char
Generates a Braille character representing a 2x4 cell block.
Braille dots are mapped to cell positions:
- Dots 1-4 map to left column (top to bottom)
- Dots 5-8 map to right column (top to bottom)
§Arguments
dot_x- X coordinate of the left cell in the blockdot_y- Y coordinate of the top cell in the block
§Returns
A Braille Unicode character (U+2800 to U+28FF)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LifeField
impl RefUnwindSafe for LifeField
impl Send for LifeField
impl Sync for LifeField
impl Unpin for LifeField
impl UnsafeUnpin for LifeField
impl UnwindSafe for LifeField
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more