← back to justinelliottcobb__Cliffy

Function bodies 1,000 total

All specs Real LLM only Function bodies
default function · rust · L380-L391 (12 LOC)
archive/cliffy-alive/src/physics.rs
    fn default() -> Self {
        Self {
            gravity: 0.1,
            damping: 0.1,
            max_velocity: 10.0,
            max_acceleration: 50.0,
            enable_collisions: true,
            connection_spring_strength: 2.0,
            thermal_strength: 0.05,
            time_step: 0.016, // ~60 FPS
        }
    }
new function · rust · L402-L407 (6 LOC)
archive/cliffy-alive/src/physics.rs
    fn new(cell_size: f64) -> Self {
        Self {
            grid: HashMap::new(),
            cell_size,
        }
    }
get_neighbors function · rust · L417-L433 (17 LOC)
archive/cliffy-alive/src/physics.rs
    fn get_neighbors(&self, position: &GA3, radius: f64) -> Vec<Uuid> {
        let mut neighbors = Vec::new();
        let center_grid = self.world_to_grid(position);
        let grid_radius = (radius / self.cell_size).ceil() as i32;

        for dx in -grid_radius..=grid_radius {
            for dy in -grid_radius..=grid_radius {
                let grid_pos = (center_grid.0 + dx, center_grid.1 + dy);
                if let Some(cell_list) = self.grid.get(&grid_pos) {
                    neighbors.extend(cell_list.iter());
                }
            }
        }

        neighbors
    }
world_to_grid function · rust · L434-L440 (7 LOC)
archive/cliffy-alive/src/physics.rs
    fn world_to_grid(&self, position: &GA3) -> (i32, i32) {
        // Access vector components directly from the multivector
        let x = (position.vector_component(0) / self.cell_size).floor() as i32;
        let y = (position.vector_component(1) / self.cell_size).floor() as i32;
        (x, y)
    }
new function · rust · L445-L453 (9 LOC)
archive/cliffy-alive/src/physics.rs
    pub fn new(config: PhysicsConfig) -> Self {
        Self {
            cell_physics: HashMap::new(),
            global_forces: Vec::new(),
            local_forces: HashMap::new(),
            config,
            spatial_grid: SpatialGrid::new(5.0), // 5-unit grid cells
        }
    }
remove_cell function · rust · L468-L482 (15 LOC)
archive/cliffy-alive/src/physics.rs
    pub fn remove_cell(&mut self, cell_id: &Uuid) {
        self.cell_physics.remove(cell_id);

        // Remove any local forces involving this cell
        let keys_to_remove: Vec<_> = self
            .local_forces
            .keys()
            .filter(|(a, b)| a == cell_id || b == cell_id)
            .cloned()
            .collect();

        for key in keys_to_remove {
            self.local_forces.remove(&key);
        }
    }
step function · rust · L502-L522 (21 LOC)
archive/cliffy-alive/src/physics.rs
    pub fn step(&mut self, dt: UITime) {
        // Update spatial grid
        self.update_spatial_grid();

        // Calculate forces
        self.calculate_forces(dt);

        // Apply connection forces
        self.apply_connection_forces(dt);

        // Update physics
        self.update_physics(dt);

        // Handle collisions
        if self.config.enable_collisions {
            self.handle_collisions();
        }

        // Enforce limits
        self.enforce_limits();
    }
Same scanner, your repo: https://repobility.com — Repobility
update_spatial_grid function · rust · L525-L532 (8 LOC)
archive/cliffy-alive/src/physics.rs
    fn update_spatial_grid(&mut self) {
        self.spatial_grid.clear();

        for (id, physics) in &self.cell_physics {
            let position = physics.position_vector();
            self.spatial_grid.insert(*id, &position);
        }
    }
calculate_forces function · rust · L535-L573 (39 LOC)
archive/cliffy-alive/src/physics.rs
    fn calculate_forces(&mut self, dt: UITime) {
        let cell_positions: HashMap<Uuid, GA3> = self
            .cell_physics
            .iter()
            .map(|(id, physics)| (*id, physics.position_vector()))
            .collect();

        // Apply global forces
        for (id, physics) in &mut self.cell_physics {
            for force in &self.global_forces {
                if let Some(position) = cell_positions.get(id) {
                    let force_vector = force.calculate_force_at(position, physics);
                    physics.apply_force(force_vector);
                }
            }
        }

        // Apply local forces
        for ((id_a, id_b), force) in &self.local_forces {
            if let (Some(pos_a), Some(pos_b)) = (cell_positions.get(id_a), cell_positions.get(id_b))
            {
                let distance_vector = pos_b.clone() - pos_a.clone();
                let distance = distance_vector.magnitude();

                if distance <= force.range && d
apply_connection_forces function · rust · L576-L611 (36 LOC)
archive/cliffy-alive/src/physics.rs
    fn apply_connection_forces(&mut self, dt: UITime) {
        // This would iterate through cell connections and apply spring forces
        // For now, we'll implement a simplified version

        let cell_positions: HashMap<Uuid, GA3> = self
            .cell_physics
            .iter()
            .map(|(id, physics)| (*id, physics.position_vector()))
            .collect();

        // Find nearby cells and apply weak attraction
        for (id, physics) in &mut self.cell_physics {
            let position = physics.position_vector();
            let neighbors = self.spatial_grid.get_neighbors(&position, 3.0);

            for neighbor_id in neighbors {
                if neighbor_id != *id {
                    if let Some(neighbor_pos) = cell_positions.get(&neighbor_id) {
                        let distance_vector = neighbor_pos.clone() - position.clone();
                        let distance = distance_vector.magnitude();

                        if distance > 0.0 && distanc
handle_collisions function · rust · L621-L645 (25 LOC)
archive/cliffy-alive/src/physics.rs
    fn handle_collisions(&mut self) {
        let cell_ids: Vec<Uuid> = self.cell_physics.keys().cloned().collect();

        for i in 0..cell_ids.len() {
            for j in (i + 1)..cell_ids.len() {
                let id_a = cell_ids[i];
                let id_b = cell_ids[j];

                if let (Some(physics_a), Some(physics_b)) =
                    (self.cell_physics.get(&id_a), self.cell_physics.get(&id_b))
                {
                    let pos_a = physics_a.position_vector();
                    let pos_b = physics_b.position_vector();
                    let distance = (pos_b - pos_a).magnitude();

                    // Collision threshold (simplified as unit radius)
                    let collision_distance = 1.0;

                    if distance < collision_distance && distance > 0.0 {
                        self.resolve_collision(id_a, id_b, distance, collision_distance);
                    }
                }
            }
        }
    }
resolve_collision function · rust · L648-L712 (65 LOC)
archive/cliffy-alive/src/physics.rs
    fn resolve_collision(
        &mut self,
        id_a: Uuid,
        id_b: Uuid,
        distance: f64,
        collision_distance: f64,
    ) {
        let (pos_a, pos_b, vel_a, vel_b, mass_a, mass_b, elasticity_a, elasticity_b) = {
            let physics_a = self.cell_physics.get(&id_a).unwrap();
            let physics_b = self.cell_physics.get(&id_b).unwrap();

            (
                physics_a.position_vector(),
                physics_b.position_vector(),
                physics_a.velocity.clone(),
                physics_b.velocity.clone(),
                physics_a.mass,
                physics_b.mass,
                physics_a.elasticity,
                physics_b.elasticity,
            )
        };

        // Collision normal
        let normal = (pos_b - pos_a)
            .normalize()
            .unwrap_or_else(|| Multivector::zero());

        // Separate objects
        let overlap = collision_distance - distance;
        let separation = &normal * (overlap 
enforce_limits function · rust · L715-L737 (23 LOC)
archive/cliffy-alive/src/physics.rs
    fn enforce_limits(&mut self) {
        for physics in self.cell_physics.values_mut() {
            // Limit velocity
            let velocity_magnitude = physics.velocity.magnitude();
            if velocity_magnitude > self.config.max_velocity {
                physics.velocity = physics
                    .velocity
                    .normalize()
                    .unwrap_or_else(|| Multivector::zero())
                    * self.config.max_velocity;
            }

            // Limit acceleration
            let acceleration_magnitude = physics.acceleration.magnitude();
            if acceleration_magnitude > self.config.max_acceleration {
                physics.acceleration = physics
                    .acceleration
                    .normalize()
                    .unwrap_or_else(|| Multivector::zero())
                    * self.config.max_acceleration;
            }
        }
    }
apply_impulse function · rust · L750-L755 (6 LOC)
archive/cliffy-alive/src/physics.rs
    pub fn apply_impulse(&mut self, cell_id: &Uuid, impulse: GA3) {
        if let Some(physics) = self.cell_physics.get_mut(cell_id) {
            let velocity_change = &impulse * (1.0 / physics.mass);
            physics.set_velocity(&physics.velocity + &velocity_change);
        }
    }
total_kinetic_energy function · rust · L758-L763 (6 LOC)
archive/cliffy-alive/src/physics.rs
    pub fn total_kinetic_energy(&self) -> f64 {
        self.cell_physics
            .values()
            .map(|physics| physics.kinetic_energy())
            .sum()
    }
Repobility · code-quality intelligence · https://repobility.com
test_cell_physics_creation function · rust · L783-L790 (8 LOC)
archive/cliffy-alive/src/physics.rs
    fn test_cell_physics_creation() {
        let position = vector3(1.0, 2.0, 0.0);
        let physics = CellPhysics::new(position, UICellType::ButtonCore);

        assert_eq!(physics.mass, 2.0);
        assert_eq!(physics.charge, 1.0);
        assert!(!physics.is_kinematic);
    }
test_force_calculation function · rust · L793-L800 (8 LOC)
archive/cliffy-alive/src/physics.rs
    fn test_force_calculation() {
        let force = Force::new(ForceType::Gravity, 1.0, vector3(0.0, -1.0, 0.0));
        let position = vector3(0.0, 0.0, 0.0);
        let physics = CellPhysics::new(position.clone(), UICellType::ButtonCore);

        let calculated_force = force.calculate_force_at(&position, &physics);
        assert!(calculated_force.magnitude() > 0.0);
    }
test_physics_engine function · rust · L803-L813 (11 LOC)
archive/cliffy-alive/src/physics.rs
    fn test_physics_engine() {
        let mut engine = PhysicsEngine::default();
        let position = vector3(0.0, 0.0, 0.0);
        let cell = UICell::new_at_position(UICellType::ButtonCore, position);

        engine.add_cell(&cell);
        assert!(engine.get_physics(&cell.id()).is_some());

        engine.step(0.016);
        // Should complete without errors
    }
test_physics_update function · rust · L823-L838 (16 LOC)
archive/cliffy-alive/src/physics.rs
    fn test_physics_update() {
        let position = vector3(0.0, 0.0, 0.0);
        let mut physics = CellPhysics::new(position, UICellType::ButtonCore);

        // Apply a force
        let force = vector3(1.0, 0.0, 0.0);
        physics.apply_force(force);

        // Update physics
        physics.update(0.1);

        // Should have moved in the positive x direction
        let new_position = physics.position_vector();
        let x_component = new_position.vector_component(0);
        assert!(x_component > 0.0);
    }
test_kinetic_energy function · rust · L841-L851 (11 LOC)
archive/cliffy-alive/src/physics.rs
    fn test_kinetic_energy() {
        let position = vector3(0.0, 0.0, 0.0);
        let mut physics = CellPhysics::new(position, UICellType::ButtonCore);

        physics.set_velocity(vector3(2.0, 0.0, 0.0));
        let ke = physics.kinetic_energy();

        // KE = 0.5 * m * v²
        let expected_ke = 0.5 * physics.mass * 4.0; // v² = 4
        assert!((ke - expected_ke).abs() < 1e-10);
    }
clear function · rust · L69-L74 (6 LOC)
archive/cliffy-alive/src/renderer.rs
    fn clear(&self) -> Result<(), RenderError> {
        // Stub implementation
        // TODO: Implement DOM clearing
        Ok(())
    }
new function · rust · L91-L97 (7 LOC)
archive/cliffy-alive/src/renderer.rs
    pub fn new(canvas_id: String, width: u32, height: u32) -> Self {
        Self {
            canvas_id,
            width,
            height,
        }
    }
base_energy_cost function · rust · L55-L74 (20 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn base_energy_cost(&self) -> UIEnergy {
        match self {
            UICellType::ButtonCore => 2.0,
            UICellType::ButtonEdge => 1.0,
            UICellType::InputField => 3.0,
            UICellType::TextDisplay => 1.5,
            UICellType::Container => 0.8,
            UICellType::Spacer => 0.2,
            UICellType::Connector => 0.5,
            UICellType::Decoration => 0.3,
            UICellType::Sensor => 1.2,
            UICellType::Memory => 1.8,
            UICellType::Generic => 1.0,
            UICellType::Header => 2.5,
            UICellType::Content => 1.8,
            UICellType::Navigation => 2.0,
            UICellType::DataDisplay => 2.2,
            UICellType::DataVisualization => 3.5,
        }
    }
Repobility's GitHub App fixes findings like these · https://github.com/apps/repobility-bot
preferred_neighbors function · rust · L77-L96 (20 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn preferred_neighbors(&self) -> Vec<UICellType> {
        match self {
            UICellType::ButtonCore => vec![UICellType::ButtonEdge, UICellType::Sensor],
            UICellType::ButtonEdge => vec![UICellType::ButtonCore, UICellType::Decoration],
            UICellType::InputField => vec![UICellType::Sensor, UICellType::Memory],
            UICellType::TextDisplay => vec![UICellType::Container, UICellType::Decoration],
            UICellType::Container => vec![UICellType::Spacer, UICellType::Connector],
            UICellType::Spacer => vec![UICellType::Container],
            UICellType::Connector => vec![UICellType::Container, UICellType::Memory],
            UICellType::Decoration => vec![UICellType::ButtonEdge, UICellType::TextDisplay],
            UICellType::Sensor => vec![UICellType::ButtonCore, UICellType::InputField],
            UICellType::Memory => vec![UICellType::InputField, UICellType::Connector],
            UICellType::Generic => vec![],
            UICell
growth_probability function · rust · L99-L118 (20 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn growth_probability(&self) -> f64 {
        match self {
            UICellType::ButtonCore => 0.1,
            UICellType::ButtonEdge => 0.3,
            UICellType::InputField => 0.2,
            UICellType::TextDisplay => 0.4,
            UICellType::Container => 0.6,
            UICellType::Spacer => 0.8,
            UICellType::Connector => 0.7,
            UICellType::Decoration => 0.9,
            UICellType::Sensor => 0.5,
            UICellType::Memory => 0.3,
            UICellType::Generic => 0.5,
            UICellType::Header => 0.2,
            UICellType::Content => 0.4,
            UICellType::Navigation => 0.3,
            UICellType::DataDisplay => 0.6,
            UICellType::DataVisualization => 0.4,
        }
    }
new function · rust · L240-L245 (6 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn new() -> Self {
        Self {
            stress_level: 0.0,
            interaction_count: 0,
        }
    }
new function · rust · L264-L286 (23 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn new() -> Self {
        let mut genes = HashMap::new();
        let mut traits = HashMap::new();

        // Initialize default genes
        genes.insert("growth_rate".to_string(), 0.5);
        genes.insert("energy_efficiency".to_string(), 0.7);
        genes.insert("cooperation".to_string(), 0.6);
        genes.insert("adaptability".to_string(), 0.4);
        genes.insert("visual_appeal".to_string(), 0.5);
        genes.insert("responsiveness".to_string(), 0.8);

        // Initialize default traits
        traits.insert("display_brightness".to_string(), 0.5);
        traits.insert("update_frequency".to_string(), 0.5);
        traits.insert("user_engagement".to_string(), 0.3);

        Self {
            genes,
            traits,
            affinities: HashMap::new(),
        }
    }
mutate function · rust · L295-L306 (12 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn mutate(&mut self, rate: f64) {
        use rand::Rng;
        let mut rng = rand::thread_rng();

        for (_, value) in self.genes.iter_mut() {
            if rng.gen::<f64>() < rate {
                let delta = rng.gen_range(-0.1..=0.1);
                *value = (*value + delta).clamp(0.0, 1.0);
            }
        }
    }
crossover function · rust · L307-L350 (44 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn crossover(&self, other: &CellGenome, _crossover_rate: f64) -> CellGenome {
        use rand::Rng;
        let mut rng = rand::thread_rng();
        let mut new_genes = HashMap::new();
        let mut new_traits = HashMap::new();
        let mut new_affinities = HashMap::new();

        // Combine genes from both parents
        for key in self.genes.keys() {
            let value = if rng.gen::<f64>() < 0.5 {
                self.genes.get(key).copied().unwrap_or(0.5)
            } else {
                other.genes.get(key).copied().unwrap_or(0.5)
            };
            new_genes.insert(key.clone(), value);
        }

        // Combine traits
        for key in self.traits.keys().chain(other.traits.keys()) {
            let value = if rng.gen::<f64>() < 0.5 {
                self.traits.get(key).copied().unwrap_or(0.5)
            } else {
                other.traits.get(key).copied().unwrap_or(0.5)
            };
            new_traits.insert(key.clone(), value);
  
has_genes_from function · rust · L363-L370 (8 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn has_genes_from(&self, other: &CellGenome) -> bool {
        for (key, _) in &other.genes {
            if self.genes.contains_key(key) {
                return true;
            }
        }
        false
    }
similarity_to function · rust · L373-L389 (17 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn similarity_to(&self, other: &CellGenome) -> f64 {
        let mut total_diff = 0.0;
        let mut count = 0;

        for (key, value) in &self.genes {
            if let Some(other_value) = other.genes.get(key) {
                total_diff += (value - other_value).abs();
                count += 1;
            }
        }

        if count == 0 {
            return 0.0;
        }

        1.0 - (total_diff / count as f64)
    }
Source: Repobility analyzer · https://repobility.com
default function · rust · L404-L413 (10 LOC)
archive/cliffy-alive/src/ui_cell.rs
    fn default() -> Self {
        Self {
            color: [0.2, 0.5, 0.8, 1.0], // Blue
            size: 1.0,
            opacity: 1.0,
            border_width: 1.0,
            border_color: [0.0, 0.0, 0.0, 1.0], // Black border
            glow_intensity: 0.0,
        }
    }
default function · rust · L427-L435 (9 LOC)
archive/cliffy-alive/src/ui_cell.rs
    fn default() -> Self {
        Self {
            interaction_radius: 5.0,
            response_speed: 1.0,
            memory_capacity: 10,
            learning_rate: 0.1,
            social_tendency: 0.5,
        }
    }
new_at_position function · rust · L450-L499 (50 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn new_at_position(cell_type: UICellType, position: GA3) -> Self {
        let id = Uuid::new_v4();
        let geometric_state = ReactiveMultivector::new(position);
        let energy = cell_type.base_energy_cost() * 10.0; // Start with 10x base cost

        let mut visual_props = VisualProperties::default();

        // Customize appearance based on cell type
        match cell_type {
            UICellType::ButtonCore => {
                visual_props.color = [0.2, 0.7, 0.3, 1.0]; // Green
                visual_props.size = 1.5;
                visual_props.glow_intensity = 0.3;
            }
            UICellType::ButtonEdge => {
                visual_props.color = [0.1, 0.6, 0.2, 1.0]; // Darker green
                visual_props.size = 1.0;
            }
            UICellType::InputField => {
                visual_props.color = [0.9, 0.9, 0.9, 1.0]; // Light gray
                visual_props.border_width = 2.0;
                visual_props.border_color = [0.5, 0.5, 
consume_energy function · rust · L557-L564 (8 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn consume_energy(&mut self, amount: UIEnergy) -> bool {
        if self.energy >= amount {
            self.energy -= amount;
            true
        } else {
            false
        }
    }
reproduce function · rust · L579-L599 (21 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn reproduce(&mut self, position: GA3) -> Option<UICell> {
        if self.state != CellState::Reproducing {
            return None;
        }

        // Cost energy for reproduction
        let reproduction_cost = self.cell_type.base_energy_cost() * 5.0;
        if !self.consume_energy(reproduction_cost) {
            return None;
        }

        // Create offspring with mutated genome
        let mut offspring = UICell::new_at_position(self.cell_type, position);
        offspring.dna = self.dna.clone();
        offspring.dna.mutate(0.05); // 5% mutation rate

        // Return to normal state
        self.state = CellState::Alive;

        Some(offspring)
    }
update_appearance function · rust · L602-L610 (9 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn update_appearance(&mut self) {
        let appeal_gene = self.dna.get_gene("visual_appeal");
        let energy_ratio = (self.energy / 100.0).clamp(0.0, 1.0);

        // Adjust visual properties based on genes and energy
        self.visual_properties.glow_intensity = appeal_gene * energy_ratio;
        self.visual_properties.opacity = 0.3 + 0.7 * energy_ratio;
        self.visual_properties.size = 0.5 + 1.5 * energy_ratio;
    }
on_interaction function · rust · L613-L628 (16 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn on_interaction(&mut self, interaction_type: InteractionType, intensity: f64) {
        match interaction_type {
            InteractionType::Click => {
                self.add_energy(intensity * 10.0);
                self.visual_properties.glow_intensity =
                    (self.visual_properties.glow_intensity + 0.5).min(1.0);
            }
            InteractionType::Hover => {
                self.visual_properties.size = (self.visual_properties.size * 1.1).min(2.0);
            }
            InteractionType::Focus => {
                self.visual_properties.border_width =
                    (self.visual_properties.border_width * 1.5).min(5.0);
            }
        }
    }
position function · rust · L638-L644 (7 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn position(&self) -> Position2D {
        let state = self.geometric_state.sample();
        Position2D {
            x: state.scalar_part(),       // Dimension 0
            y: state.vector_component(0), // Dimension 1 (e1)
        }
    }
Same scanner, your repo: https://repobility.com — Repobility
size function · rust · L647-L653 (7 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn size(&self) -> Size2D {
        let state = self.geometric_state.sample();
        Size2D {
            width: state.vector_component(1).abs().max(10.0), // Dimension 2 (e2), minimum size
            height: state.vector_component(2).abs().max(10.0), // Dimension 3 (e3), minimum size
        }
    }
set_position function · rust · L668-L673 (6 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn set_position(&mut self, x: f64, y: f64) {
        let mut current = self.geometric_state.sample();
        current.set_scalar(x);
        current.set_vector_component(0, y); // e1
        self.geometric_state.set(current);
    }
interaction_force function · rust · L681-L700 (20 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn interaction_force(&self, other: &UICell) -> Force2D {
        let my_pos = self.position();
        let other_pos = other.position();

        let dx = other_pos.x - my_pos.x;
        let dy = other_pos.y - my_pos.y;
        let distance = (dx * dx + dy * dy).sqrt();

        if distance < 1.0 {
            return Force2D { x: 0.0, y: 0.0 };
        }

        let affinity = self.affinity_to(other);
        let force_magnitude = affinity / (distance * distance);

        Force2D {
            x: force_magnitude * dx / distance,
            y: force_magnitude * dy / distance,
        }
    }
metabolize function · rust · L703-L713 (11 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn metabolize(&mut self, dt: UITime) -> Result<(), crate::AliveError> {
        let base_cost = self.cell_type.base_energy_cost() * dt;
        let efficiency = self.dna.get_gene("energy_efficiency");
        let actual_cost = base_cost * (2.0 - efficiency);

        if !self.consume_energy(actual_cost) {
            self.state = CellState::Dying;
        }

        Ok(())
    }
apply_geometric_mutation function · rust · L752-L761 (10 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn apply_geometric_mutation(&mut self, strength: f64) {
        let mut current = self.geometric_state.sample();
        let random_dx = (rand::random::<f64>() - 0.5) * strength * 20.0;
        let random_dy = (rand::random::<f64>() - 0.5) * strength * 20.0;

        current.set_scalar(current.scalar_part() + random_dx);
        current.set_vector_component(0, current.vector_component(0) + random_dy); // e1

        self.geometric_state.set(current);
    }
get_update_frequency function · rust · L810-L816 (7 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn get_update_frequency(&self) -> f64 {
        self.dna
            .traits
            .get("update_frequency")
            .copied()
            .unwrap_or(0.5)
    }
express_genes function · rust · L819-L826 (8 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn express_genes(&mut self) {
        // Update opacity based on brightness gene
        if let Some(brightness) = self.dna.traits.get("display_brightness") {
            let mut current = self.geometric_state.sample();
            current.set(3, brightness * 2.0 - 1.0); // e12 bivector component, convert 0-1 to -1-1
            self.geometric_state.set(current);
        }
    }
is_alive function · rust · L849-L854 (6 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn is_alive(&self) -> bool {
        matches!(
            self.state,
            CellState::Alive | CellState::Reproducing | CellState::Focused
        )
    }
Repobility · code-quality intelligence · https://repobility.com
step function · rust · L862-L876 (15 LOC)
archive/cliffy-alive/src/ui_cell.rs
    pub fn step(&mut self, dt: UITime) {
        self.age += dt;

        // Consume energy over time
        let energy_cost = self.cell_type.base_energy_cost() * dt;
        self.energy -= energy_cost;

        // Update vitals (health is derived from energy level and stress)
        // Note: Health can be calculated as a function of energy and stress_level when needed

        // Check if cell should die
        if self.energy <= 0.0 {
            self.state = CellState::Dead;
        }
    }
step function · rust · L895-L929 (35 LOC)
archive/cliffy-alive/src/ui_cell.rs
    fn step(&mut self, dt: UITime) {
        self.age += dt;

        // Base metabolism - consume energy over time
        let base_cost = self.cell_type.base_energy_cost() * dt;
        let efficiency = self.dna.get_gene("energy_efficiency");
        let actual_cost = base_cost * (2.0 - efficiency); // More efficient = less cost

        if !self.consume_energy(actual_cost) {
            // Not enough energy - start dying
            if self.state == CellState::Alive {
                self.state = CellState::Dying;
            }
        }

        // Update state based on energy
        match self.state {
            CellState::Dying => {
                if self.energy <= 0.0 {
                    self.state = CellState::Dead;
                }
            }
            CellState::Reproducing => {
                // Reproduction takes time and energy
                if self.age % 10.0 < dt {
                    self.state = CellState::Alive;
                }
            }
         
is_alive function · rust · L930-L936 (7 LOC)
archive/cliffy-alive/src/ui_cell.rs
    fn is_alive(&self) -> bool {
        matches!(
            self.state,
            CellState::Alive | CellState::Reproducing | CellState::Mutating
        )
    }
‹ prevpage 3 / 20next ›