Skip to main content

ConditionalOperation

Struct ConditionalOperation 

Source
pub struct ConditionalOperation {
    pub operation: PipelineOperation,
    pub condition: Option<PipelineCondition>,
    pub if_true: Vec<ConditionalOperation>,
    pub if_false: Vec<ConditionalOperation>,
}
Expand description

A conditional operation in the pipeline

Fields§

§operation: PipelineOperation

The operation to perform

§condition: Option<PipelineCondition>

Optional condition that must be met

§if_true: Vec<ConditionalOperation>

Operations to execute if condition is true

§if_false: Vec<ConditionalOperation>

Operations to execute if condition is false

Implementations§

Source§

impl ConditionalOperation

Source

pub fn simple(operation: PipelineOperation) -> Self

Create simple operation without conditions

Examples found in repository?
examples/phase2_demo.rs (lines 27-30)
16fn demo_conditional_pipeline() {
17    println!("🔀 Demo 1: Conditional Pipeline Operations");
18
19    let mut grid = Grid::new(30, 20);
20    let mut context = PipelineContext::new();
21    let mut rng = Rng::new(12345);
22
23    // Create conditional pipeline
24    let mut pipeline = ConditionalPipeline::new();
25
26    // Add algorithm operation
27    pipeline.add_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
28        name: "bsp".to_string(),
29        seed: Some(12345),
30    }));
31
32    // Add conditional operation based on floor density
33    pipeline.add_operation(ConditionalOperation::conditional(
34        PipelineOperation::Log {
35            message: "Evaluating floor density".to_string(),
36        },
37        PipelineCondition::Density {
38            min: Some(0.2),
39            max: Some(0.6),
40        },
41        vec![ConditionalOperation::simple(
42            PipelineOperation::SetParameter {
43                key: "density_status".to_string(),
44                value: "acceptable".to_string(),
45            },
46        )],
47        vec![ConditionalOperation::simple(
48            PipelineOperation::SetParameter {
49                key: "density_status".to_string(),
50                value: "out_of_range".to_string(),
51            },
52        )],
53    ));
54
55    // Execute pipeline
56    let result = pipeline.execute(&mut grid, &mut context, &mut rng);
57
58    println!(
59        "  Pipeline execution: {}",
60        if result.success {
61            "✅ Success"
62        } else {
63            "❌ Failed"
64        }
65    );
66    if let Some(msg) = result.message {
67        println!("  Message: {}", msg);
68    }
69
70    println!("  Floor tiles: {}", grid.count(|t| t.is_floor()));
71    println!(
72        "  Density status: {}",
73        context
74            .get_parameter("density_status")
75            .unwrap_or(&"unknown".to_string())
76    );
77    println!("  Execution log: {:?}", context.execution_history());
78    println!();
79}
80
81fn demo_pipeline_templates() {
82    println!("📋 Demo 2: Pipeline Templates");
83
84    // Create custom template
85    let template = PipelineTemplate::new("custom_dungeon", "Customizable dungeon template")
86        .with_parameter("algorithm", "cellular")
87        .with_parameter("seed", "54321")
88        .with_parameter("type", "dungeon")
89        .with_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
90            name: "{algorithm}".to_string(),
91            seed: Some(54321),
92        }))
93        .with_operation(ConditionalOperation::simple(
94            PipelineOperation::SetParameter {
95                key: "generation_type".to_string(),
96                value: "{type}".to_string(),
97            },
98        ));
99
100    // Instantiate with custom parameters
101    let mut custom_params = std::collections::HashMap::new();
102    custom_params.insert("algorithm".to_string(), "bsp".to_string());
103    custom_params.insert("type".to_string(), "fortress".to_string());
104
105    let pipeline = template.instantiate(Some(custom_params));
106
107    let mut grid = Grid::new(25, 25);
108    let mut context = PipelineContext::new();
109    let mut rng = Rng::new(98765);
110
111    let result = pipeline.execute(&mut grid, &mut context, &mut rng);
112
113    println!("  Template: {}", template.name);
114    println!("  Description: {}", template.description);
115    println!(
116        "  Execution: {}",
117        if result.success {
118            "✅ Success"
119        } else {
120            "❌ Failed"
121        }
122    );
123    println!(
124        "  Generation type: {}",
125        context
126            .get_parameter("generation_type")
127            .unwrap_or(&"unknown".to_string())
128    );
129    println!("  Floor tiles: {}", grid.count(|t| t.is_floor()));
130    println!();
131}
More examples
Hide additional examples
examples/conditional_pipelines.rs (lines 12-15)
3fn main() {
4    println!("=== Conditional Pipeline Demo ===\n");
5
6    // Demo 1: Simple conditional pipeline
7    println!("1. Density-Based Conditional Pipeline:");
8
9    let mut pipeline = ConditionalPipeline::new();
10
11    // Generate initial map
12    pipeline.add_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
13        name: "cellular".to_string(),
14        seed: Some(12345),
15    }));
16
17    // Check density and apply different effects
18    pipeline.add_operation(ConditionalOperation::conditional(
19        PipelineOperation::Log {
20            message: "Checking density".to_string(),
21        },
22        PipelineCondition::Density {
23            min: Some(0.3),
24            max: Some(0.7),
25        },
26        vec![
27            ConditionalOperation::simple(PipelineOperation::SetParameter {
28                key: "quality".to_string(),
29                value: "good".to_string(),
30            }),
31            ConditionalOperation::simple(PipelineOperation::Log {
32                message: "Density is acceptable".to_string(),
33            }),
34        ],
35        vec![
36            ConditionalOperation::simple(PipelineOperation::SetParameter {
37                key: "quality".to_string(),
38                value: "poor".to_string(),
39            }),
40            ConditionalOperation::simple(PipelineOperation::Log {
41                message: "Density needs adjustment".to_string(),
42            }),
43        ],
44    ));
45
46    let mut grid = Grid::new(40, 30);
47    let mut context = PipelineContext::new();
48    let mut rng = Rng::new(12345);
49
50    let result = pipeline.execute(&mut grid, &mut context, &mut rng);
51
52    println!(
53        "  Result: {}",
54        if result.success {
55            "✅ Success"
56        } else {
57            "❌ Failed"
58        }
59    );
60    println!("  Floor tiles: {}", grid.count(|t| t.is_floor()));
61    println!(
62        "  Quality assessment: {}",
63        context
64            .get_parameter("quality")
65            .unwrap_or(&"unknown".to_string())
66    );
67    println!("  Execution steps: {}", context.execution_history().len());
68
69    // Demo 2: Floor count conditional
70    println!("\n2. Floor Count Conditional Pipeline:");
71
72    let mut pipeline2 = ConditionalPipeline::new();
73
74    pipeline2.add_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
75        name: "bsp".to_string(),
76        seed: Some(54321),
77    }));
78
79    pipeline2.add_operation(ConditionalOperation::conditional(
80        PipelineOperation::Log {
81            message: "Evaluating floor count".to_string(),
82        },
83        PipelineCondition::FloorCount {
84            min: Some(100),
85            max: Some(500),
86        },
87        vec![ConditionalOperation::simple(
88            PipelineOperation::SetParameter {
89                key: "size_category".to_string(),
90                value: "medium".to_string(),
91            },
92        )],
93        vec![ConditionalOperation::simple(
94            PipelineOperation::SetParameter {
95                key: "size_category".to_string(),
96                value: "large_or_small".to_string(),
97            },
98        )],
99    ));
100
101    let mut grid2 = Grid::new(35, 25);
102    let mut context2 = PipelineContext::new();
103    let mut rng2 = Rng::new(54321);
104
105    let result2 = pipeline2.execute(&mut grid2, &mut context2, &mut rng2);
106
107    println!(
108        "  Result: {}",
109        if result2.success {
110            "✅ Success"
111        } else {
112            "❌ Failed"
113        }
114    );
115    println!("  Floor tiles: {}", grid2.count(|t| t.is_floor()));
116    println!(
117        "  Size category: {}",
118        context2
119            .get_parameter("size_category")
120            .unwrap_or(&"unknown".to_string())
121    );
122
123    println!("\n  Execution log:");
124    for (i, step) in context2.execution_history().iter().enumerate() {
125        println!("    {}. {}", i + 1, step);
126    }
127}
examples/pipeline_templates.rs (lines 50-52)
3fn main() {
4    println!("=== Pipeline Templates Demo ===\n");
5
6    // Demo 1: Using built-in templates
7    println!("1. Built-in Template Library:");
8
9    let library = TemplateLibrary::new();
10    println!("  Available templates:");
11    for name in library.template_names() {
12        if let Some(template) = library.get_template(name) {
13            println!("    - {}: {}", name, template.description);
14        }
15    }
16
17    // Use the simple_dungeon template
18    if let Some(template) = library.get_template("simple_dungeon") {
19        let pipeline = template.instantiate(None);
20
21        let mut grid = Grid::new(40, 30);
22        let mut context = PipelineContext::new();
23        let mut rng = Rng::new(11111);
24
25        let result = pipeline.execute(&mut grid, &mut context, &mut rng);
26
27        println!("\n  Executed 'simple_dungeon' template:");
28        println!(
29            "    Result: {}",
30            if result.success {
31                "✅ Success"
32            } else {
33                "❌ Failed"
34            }
35        );
36        println!("    Floor tiles: {}", grid.count(|t| t.is_floor()));
37        println!("    Steps executed: {}", context.execution_history().len());
38    }
39
40    // Demo 2: Custom template with parameters
41    println!("\n2. Custom Parameterized Template:");
42
43    let custom_template = PipelineTemplate::new(
44        "adaptive_dungeon",
45        "Dungeon that adapts based on size parameter",
46    )
47    .with_parameter("size", "medium")
48    .with_parameter("algorithm", "bsp")
49    .with_parameter("complexity", "normal")
50    .with_operation(ConditionalOperation::simple(PipelineOperation::Log {
51        message: "Generating {size} dungeon with {algorithm}".to_string(),
52    }))
53    .with_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
54        name: "{algorithm}".to_string(),
55        seed: Some(22222),
56    }))
57    .with_operation(ConditionalOperation::simple(
58        PipelineOperation::SetParameter {
59            key: "dungeon_type".to_string(),
60            value: "{size}_{complexity}".to_string(),
61        },
62    ));
63
64    // Instantiate with default parameters
65    println!("  Default parameters:");
66    let pipeline1 = custom_template.instantiate(None);
67    let mut grid1 = Grid::new(30, 20);
68    let mut context1 = PipelineContext::new();
69    let mut rng1 = Rng::new(22222);
70
71    let result1 = pipeline1.execute(&mut grid1, &mut context1, &mut rng1);
72    println!(
73        "    Result: {}",
74        if result1.success {
75            "✅ Success"
76        } else {
77            "❌ Failed"
78        }
79    );
80    println!(
81        "    Dungeon type: {}",
82        context1
83            .get_parameter("dungeon_type")
84            .unwrap_or(&"unknown".to_string())
85    );
86
87    // Instantiate with custom parameters
88    println!("  Custom parameters:");
89    let mut custom_params = std::collections::HashMap::new();
90    custom_params.insert("size".to_string(), "large".to_string());
91    custom_params.insert("algorithm".to_string(), "cellular".to_string());
92    custom_params.insert("complexity".to_string(), "high".to_string());
93
94    let pipeline2 = custom_template.instantiate(Some(custom_params));
95    let mut grid2 = Grid::new(50, 40);
96    let mut context2 = PipelineContext::new();
97    let mut rng2 = Rng::new(33333);
98
99    let result2 = pipeline2.execute(&mut grid2, &mut context2, &mut rng2);
100    println!(
101        "    Result: {}",
102        if result2.success {
103            "✅ Success"
104        } else {
105            "❌ Failed"
106        }
107    );
108    println!(
109        "    Dungeon type: {}",
110        context2
111            .get_parameter("dungeon_type")
112            .unwrap_or(&"unknown".to_string())
113    );
114    println!("    Floor tiles: {}", grid2.count(|t| t.is_floor()));
115
116    // Demo 3: Template with conditional logic
117    println!("\n3. Template with Conditional Logic:");
118
119    let smart_template = PipelineTemplate::new(
120        "smart_generator",
121        "Generator that chooses algorithm based on size",
122    )
123    .with_parameter("width", "40")
124    .with_parameter("height", "30")
125    .with_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
126        name: "bsp".to_string(),
127        seed: Some(44444),
128    }))
129    .with_operation(ConditionalOperation::conditional(
130        PipelineOperation::Log {
131            message: "Analyzing generated map".to_string(),
132        },
133        PipelineCondition::Density {
134            min: Some(0.2),
135            max: Some(0.6),
136        },
137        vec![ConditionalOperation::simple(
138            PipelineOperation::SetParameter {
139                key: "analysis".to_string(),
140                value: "optimal_density".to_string(),
141            },
142        )],
143        vec![ConditionalOperation::simple(
144            PipelineOperation::SetParameter {
145                key: "analysis".to_string(),
146                value: "suboptimal_density".to_string(),
147            },
148        )],
149    ));
150
151    let pipeline3 = smart_template.instantiate(None);
152    let mut grid3 = Grid::new(40, 30);
153    let mut context3 = PipelineContext::new();
154    let mut rng3 = Rng::new(44444);
155
156    let result3 = pipeline3.execute(&mut grid3, &mut context3, &mut rng3);
157    println!(
158        "  Result: {}",
159        if result3.success {
160            "✅ Success"
161        } else {
162            "❌ Failed"
163        }
164    );
165    println!(
166        "  Analysis: {}",
167        context3
168            .get_parameter("analysis")
169            .unwrap_or(&"unknown".to_string())
170    );
171    println!(
172        "  Density: {:.2}",
173        grid3.count(|t| t.is_floor()) as f32 / (grid3.width() * grid3.height()) as f32
174    );
175}
Source

pub fn conditional( operation: PipelineOperation, condition: PipelineCondition, if_true: Vec<ConditionalOperation>, if_false: Vec<ConditionalOperation>, ) -> Self

Create conditional operation

Examples found in repository?
examples/phase2_demo.rs (lines 33-53)
16fn demo_conditional_pipeline() {
17    println!("🔀 Demo 1: Conditional Pipeline Operations");
18
19    let mut grid = Grid::new(30, 20);
20    let mut context = PipelineContext::new();
21    let mut rng = Rng::new(12345);
22
23    // Create conditional pipeline
24    let mut pipeline = ConditionalPipeline::new();
25
26    // Add algorithm operation
27    pipeline.add_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
28        name: "bsp".to_string(),
29        seed: Some(12345),
30    }));
31
32    // Add conditional operation based on floor density
33    pipeline.add_operation(ConditionalOperation::conditional(
34        PipelineOperation::Log {
35            message: "Evaluating floor density".to_string(),
36        },
37        PipelineCondition::Density {
38            min: Some(0.2),
39            max: Some(0.6),
40        },
41        vec![ConditionalOperation::simple(
42            PipelineOperation::SetParameter {
43                key: "density_status".to_string(),
44                value: "acceptable".to_string(),
45            },
46        )],
47        vec![ConditionalOperation::simple(
48            PipelineOperation::SetParameter {
49                key: "density_status".to_string(),
50                value: "out_of_range".to_string(),
51            },
52        )],
53    ));
54
55    // Execute pipeline
56    let result = pipeline.execute(&mut grid, &mut context, &mut rng);
57
58    println!(
59        "  Pipeline execution: {}",
60        if result.success {
61            "✅ Success"
62        } else {
63            "❌ Failed"
64        }
65    );
66    if let Some(msg) = result.message {
67        println!("  Message: {}", msg);
68    }
69
70    println!("  Floor tiles: {}", grid.count(|t| t.is_floor()));
71    println!(
72        "  Density status: {}",
73        context
74            .get_parameter("density_status")
75            .unwrap_or(&"unknown".to_string())
76    );
77    println!("  Execution log: {:?}", context.execution_history());
78    println!();
79}
More examples
Hide additional examples
examples/conditional_pipelines.rs (lines 18-44)
3fn main() {
4    println!("=== Conditional Pipeline Demo ===\n");
5
6    // Demo 1: Simple conditional pipeline
7    println!("1. Density-Based Conditional Pipeline:");
8
9    let mut pipeline = ConditionalPipeline::new();
10
11    // Generate initial map
12    pipeline.add_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
13        name: "cellular".to_string(),
14        seed: Some(12345),
15    }));
16
17    // Check density and apply different effects
18    pipeline.add_operation(ConditionalOperation::conditional(
19        PipelineOperation::Log {
20            message: "Checking density".to_string(),
21        },
22        PipelineCondition::Density {
23            min: Some(0.3),
24            max: Some(0.7),
25        },
26        vec![
27            ConditionalOperation::simple(PipelineOperation::SetParameter {
28                key: "quality".to_string(),
29                value: "good".to_string(),
30            }),
31            ConditionalOperation::simple(PipelineOperation::Log {
32                message: "Density is acceptable".to_string(),
33            }),
34        ],
35        vec![
36            ConditionalOperation::simple(PipelineOperation::SetParameter {
37                key: "quality".to_string(),
38                value: "poor".to_string(),
39            }),
40            ConditionalOperation::simple(PipelineOperation::Log {
41                message: "Density needs adjustment".to_string(),
42            }),
43        ],
44    ));
45
46    let mut grid = Grid::new(40, 30);
47    let mut context = PipelineContext::new();
48    let mut rng = Rng::new(12345);
49
50    let result = pipeline.execute(&mut grid, &mut context, &mut rng);
51
52    println!(
53        "  Result: {}",
54        if result.success {
55            "✅ Success"
56        } else {
57            "❌ Failed"
58        }
59    );
60    println!("  Floor tiles: {}", grid.count(|t| t.is_floor()));
61    println!(
62        "  Quality assessment: {}",
63        context
64            .get_parameter("quality")
65            .unwrap_or(&"unknown".to_string())
66    );
67    println!("  Execution steps: {}", context.execution_history().len());
68
69    // Demo 2: Floor count conditional
70    println!("\n2. Floor Count Conditional Pipeline:");
71
72    let mut pipeline2 = ConditionalPipeline::new();
73
74    pipeline2.add_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
75        name: "bsp".to_string(),
76        seed: Some(54321),
77    }));
78
79    pipeline2.add_operation(ConditionalOperation::conditional(
80        PipelineOperation::Log {
81            message: "Evaluating floor count".to_string(),
82        },
83        PipelineCondition::FloorCount {
84            min: Some(100),
85            max: Some(500),
86        },
87        vec![ConditionalOperation::simple(
88            PipelineOperation::SetParameter {
89                key: "size_category".to_string(),
90                value: "medium".to_string(),
91            },
92        )],
93        vec![ConditionalOperation::simple(
94            PipelineOperation::SetParameter {
95                key: "size_category".to_string(),
96                value: "large_or_small".to_string(),
97            },
98        )],
99    ));
100
101    let mut grid2 = Grid::new(35, 25);
102    let mut context2 = PipelineContext::new();
103    let mut rng2 = Rng::new(54321);
104
105    let result2 = pipeline2.execute(&mut grid2, &mut context2, &mut rng2);
106
107    println!(
108        "  Result: {}",
109        if result2.success {
110            "✅ Success"
111        } else {
112            "❌ Failed"
113        }
114    );
115    println!("  Floor tiles: {}", grid2.count(|t| t.is_floor()));
116    println!(
117        "  Size category: {}",
118        context2
119            .get_parameter("size_category")
120            .unwrap_or(&"unknown".to_string())
121    );
122
123    println!("\n  Execution log:");
124    for (i, step) in context2.execution_history().iter().enumerate() {
125        println!("    {}. {}", i + 1, step);
126    }
127}
examples/pipeline_templates.rs (lines 129-149)
3fn main() {
4    println!("=== Pipeline Templates Demo ===\n");
5
6    // Demo 1: Using built-in templates
7    println!("1. Built-in Template Library:");
8
9    let library = TemplateLibrary::new();
10    println!("  Available templates:");
11    for name in library.template_names() {
12        if let Some(template) = library.get_template(name) {
13            println!("    - {}: {}", name, template.description);
14        }
15    }
16
17    // Use the simple_dungeon template
18    if let Some(template) = library.get_template("simple_dungeon") {
19        let pipeline = template.instantiate(None);
20
21        let mut grid = Grid::new(40, 30);
22        let mut context = PipelineContext::new();
23        let mut rng = Rng::new(11111);
24
25        let result = pipeline.execute(&mut grid, &mut context, &mut rng);
26
27        println!("\n  Executed 'simple_dungeon' template:");
28        println!(
29            "    Result: {}",
30            if result.success {
31                "✅ Success"
32            } else {
33                "❌ Failed"
34            }
35        );
36        println!("    Floor tiles: {}", grid.count(|t| t.is_floor()));
37        println!("    Steps executed: {}", context.execution_history().len());
38    }
39
40    // Demo 2: Custom template with parameters
41    println!("\n2. Custom Parameterized Template:");
42
43    let custom_template = PipelineTemplate::new(
44        "adaptive_dungeon",
45        "Dungeon that adapts based on size parameter",
46    )
47    .with_parameter("size", "medium")
48    .with_parameter("algorithm", "bsp")
49    .with_parameter("complexity", "normal")
50    .with_operation(ConditionalOperation::simple(PipelineOperation::Log {
51        message: "Generating {size} dungeon with {algorithm}".to_string(),
52    }))
53    .with_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
54        name: "{algorithm}".to_string(),
55        seed: Some(22222),
56    }))
57    .with_operation(ConditionalOperation::simple(
58        PipelineOperation::SetParameter {
59            key: "dungeon_type".to_string(),
60            value: "{size}_{complexity}".to_string(),
61        },
62    ));
63
64    // Instantiate with default parameters
65    println!("  Default parameters:");
66    let pipeline1 = custom_template.instantiate(None);
67    let mut grid1 = Grid::new(30, 20);
68    let mut context1 = PipelineContext::new();
69    let mut rng1 = Rng::new(22222);
70
71    let result1 = pipeline1.execute(&mut grid1, &mut context1, &mut rng1);
72    println!(
73        "    Result: {}",
74        if result1.success {
75            "✅ Success"
76        } else {
77            "❌ Failed"
78        }
79    );
80    println!(
81        "    Dungeon type: {}",
82        context1
83            .get_parameter("dungeon_type")
84            .unwrap_or(&"unknown".to_string())
85    );
86
87    // Instantiate with custom parameters
88    println!("  Custom parameters:");
89    let mut custom_params = std::collections::HashMap::new();
90    custom_params.insert("size".to_string(), "large".to_string());
91    custom_params.insert("algorithm".to_string(), "cellular".to_string());
92    custom_params.insert("complexity".to_string(), "high".to_string());
93
94    let pipeline2 = custom_template.instantiate(Some(custom_params));
95    let mut grid2 = Grid::new(50, 40);
96    let mut context2 = PipelineContext::new();
97    let mut rng2 = Rng::new(33333);
98
99    let result2 = pipeline2.execute(&mut grid2, &mut context2, &mut rng2);
100    println!(
101        "    Result: {}",
102        if result2.success {
103            "✅ Success"
104        } else {
105            "❌ Failed"
106        }
107    );
108    println!(
109        "    Dungeon type: {}",
110        context2
111            .get_parameter("dungeon_type")
112            .unwrap_or(&"unknown".to_string())
113    );
114    println!("    Floor tiles: {}", grid2.count(|t| t.is_floor()));
115
116    // Demo 3: Template with conditional logic
117    println!("\n3. Template with Conditional Logic:");
118
119    let smart_template = PipelineTemplate::new(
120        "smart_generator",
121        "Generator that chooses algorithm based on size",
122    )
123    .with_parameter("width", "40")
124    .with_parameter("height", "30")
125    .with_operation(ConditionalOperation::simple(PipelineOperation::Algorithm {
126        name: "bsp".to_string(),
127        seed: Some(44444),
128    }))
129    .with_operation(ConditionalOperation::conditional(
130        PipelineOperation::Log {
131            message: "Analyzing generated map".to_string(),
132        },
133        PipelineCondition::Density {
134            min: Some(0.2),
135            max: Some(0.6),
136        },
137        vec![ConditionalOperation::simple(
138            PipelineOperation::SetParameter {
139                key: "analysis".to_string(),
140                value: "optimal_density".to_string(),
141            },
142        )],
143        vec![ConditionalOperation::simple(
144            PipelineOperation::SetParameter {
145                key: "analysis".to_string(),
146                value: "suboptimal_density".to_string(),
147            },
148        )],
149    ));
150
151    let pipeline3 = smart_template.instantiate(None);
152    let mut grid3 = Grid::new(40, 30);
153    let mut context3 = PipelineContext::new();
154    let mut rng3 = Rng::new(44444);
155
156    let result3 = pipeline3.execute(&mut grid3, &mut context3, &mut rng3);
157    println!(
158        "  Result: {}",
159        if result3.success {
160            "✅ Success"
161        } else {
162            "❌ Failed"
163        }
164    );
165    println!(
166        "  Analysis: {}",
167        context3
168            .get_parameter("analysis")
169            .unwrap_or(&"unknown".to_string())
170    );
171    println!(
172        "  Density: {:.2}",
173        grid3.count(|t| t.is_floor()) as f32 / (grid3.width() * grid3.height()) as f32
174    );
175}

Trait Implementations§

Source§

impl Clone for ConditionalOperation

Source§

fn clone(&self) -> ConditionalOperation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConditionalOperation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V