From 92bcce17719daddaa35634fa8a6d84466ab53398 Mon Sep 17 00:00:00 2001 From: Tristan Murphy <72839119+HyperCodec@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:54:34 +0000 Subject: [PATCH] create perform_generations method --- genetic-rs-common/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/genetic-rs-common/src/lib.rs b/genetic-rs-common/src/lib.rs index 7cfaa3d..859a638 100644 --- a/genetic-rs-common/src/lib.rs +++ b/genetic-rs-common/src/lib.rs @@ -158,6 +158,13 @@ where self.next_gen.next_gen(rewards) }); } + + /// Calls [`next_generation`][GeneticSim::next_generation] `count` number of times. + pub fn perform_generations(&mut self, count: usize) { + for _ in 0..count { + self.next_generation(); + } + } } #[cfg(feature = "rayon")] @@ -191,6 +198,13 @@ where self.next_gen.next_gen(rewards) }); } + + /// Calls [`next_generation`][GeneticSim::next_generation] `count` number of times. + pub fn perform_generations(&mut self, count: usize) { + for _ in 0..count { + self.next_generation(); + } + } } #[cfg(feature = "genrand")]