Skip to content

Commit

Permalink
Move depth and searches calculation to reusable static functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoupey committed Dec 2, 2024
1 parent a29b980 commit 0569fb3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/structures/cl_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,28 @@ void update_port(Servers& servers, std::string_view value) {
}
}

void CLArgs::set_exploration_level(unsigned exploration_level) {
depth = exploration_level;
unsigned CLArgs::get_depth(unsigned exploration_level) {
return exploration_level;
}

unsigned CLArgs::get_nb_searches(unsigned exploration_level) {
assert(exploration_level <= MAX_EXPLORATION_LEVEL);

nb_searches = 4 * (exploration_level + 1);
unsigned nb_searches = 4 * (exploration_level + 1);
if (exploration_level >= 4) {
nb_searches += 4;
}
if (exploration_level == MAX_EXPLORATION_LEVEL) {
nb_searches += 4;
}

return nb_searches;
}

void CLArgs::set_exploration_level(unsigned exploration_level) {
depth = get_depth(exploration_level);

nb_searches = get_nb_searches(exploration_level);
}

} // namespace vroom::io
4 changes: 4 additions & 0 deletions src/structures/cl_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ struct CLArgs {
unsigned nb_searches; // derived from -x
unsigned depth; // derived from -x

static unsigned get_depth(unsigned exploration_level);

static unsigned get_nb_searches(unsigned exploration_level);

void set_exploration_level(unsigned exploration_level);
};

Expand Down

0 comments on commit 0569fb3

Please sign in to comment.