From 27e319d0203d5a61fa8d3e21bac9d7e78f2c8e32 Mon Sep 17 00:00:00 2001 From: Moritz Sallermann Date: Fri, 22 Mar 2024 12:53:32 +0000 Subject: [PATCH] Simulation: Put agents_from_file outside of if Less code repetition, less confusing, less shitty Co-authored-by: Amrita Goswami --- include/simulation.hpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/include/simulation.hpp b/include/simulation.hpp index 5e7c72b..41fd4ea 100644 --- a/include/simulation.hpp +++ b/include/simulation.hpp @@ -73,11 +73,6 @@ class Simulation : public SimulationInterface auto model = std::make_unique( degroot_settings, network ); return model; }(); - - if( cli_agent_file.has_value() ) - { - network.agents = agents_from_file( cli_agent_file.value() ); - } } else if( options.model == Config::Model::DeffuantModel ) { @@ -90,11 +85,6 @@ class Simulation : public SimulationInterface deffuant_settings, network, gen, deffuant_settings.use_network ); return model; }(); - - if( cli_agent_file.has_value() ) - { - network.agents = agents_from_file( cli_agent_file.value() ); - } } } else if constexpr( std::is_same_v ) @@ -106,11 +96,11 @@ class Simulation : public SimulationInterface auto model = std::make_unique( activitydriven_settings, network, gen ); return model; }(); + } - if( cli_agent_file.has_value() ) - { - network.agents = agents_from_file( cli_agent_file.value() ); - } + if( cli_agent_file.has_value() ) + { + network.agents = agents_from_file( cli_agent_file.value() ); } }