From 0ece4b72db22139db51e8f5f37c25f24c84f3e43 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 17 Apr 2025 10:50:57 +0200 Subject: Small rework of optimal vs maxsols I wanted to make the "optimal" and "maxsolutions" options mutually exclusive, but in the end I decided there is value in keeping both (e.g. for specifying a limit to the number of solutions when asking for "all" optimal"). Now optimal cannot be negative anymore, for the same reason of maxsolutions. The interface user (shell, UI) will have to take care of handling this in a way that makes sense for the user. Usually this means setting the maximum number of solutions to UINT_MAX (or a similar very high number) when the user wants "all optimal". --- src/solvers/solutions.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/solvers/solutions.h') diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index e65f299..95c1d1a 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h @@ -43,8 +43,6 @@ solution_list_init(solution_list_t sols[static 1], size_t n, char buf[n]) sols->size = n; sols->used = 0; sols->buf = buf; - - /* Ensure string buffer is NULL-terminated */ sols->buf[0] = '\0'; return true; @@ -215,15 +213,8 @@ solutions_done( int8_t depth ) { - if (list->nsols >= settings->maxsolutions) - return true; - - if (depth > settings->maxmoves) - return true; - if (list->nsols > 0 && settings->optimal >= 0 && - depth > list->shortest_sol + settings->optimal) - return true; - - return false; + return depth > settings->maxmoves || + depth > list->shortest_sol + settings->optimal || + list->nsols >= settings->maxsolutions; } -- cgit v1.3