From f0245518ba34d3a41f0ca04f4ecb9a231e0ff4df Mon Sep 17 00:00:00 2001 From: Terje Date: Fri, 26 Jan 2024 15:00:28 +0100 Subject: [PATCH] . --- README.md | 5 +++++ src/noobprobe/noobprobe.c | 13 ++++++++++++- src/noobprobe/noobprobe.h | 1 + src/uci.c | 2 ++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2962d4e7..0985a716 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,11 @@ Weiss appears in most rating lists, and can be seen competing at [TCEC](https:// * #### NoobBook Allow Weiss to query and play moves suggested by [noobpwnftw's online opening database](https://www.chessdb.cn/queryc_en/). +* #### NoobBookMode + Sets the query mode to use (see [dbcn docs](https://www.chessdb.cn/cloudbookc_api_en.html)): + - best - chooses randomly from the moves with scores close to the best. Stops if all moves' scores are below a threshold. + - all - chooses the move with the highest score (first in the returned list). Only stops if there are no moves with scores. + * #### NoobBookLimit Limit the use of NoobBook to the first x moves of the game. Only relevant with NoobBook set to true. diff --git a/src/noobprobe/noobprobe.c b/src/noobprobe/noobprobe.c index 5c5badb5..c7df4464 100644 --- a/src/noobprobe/noobprobe.c +++ b/src/noobprobe/noobprobe.c @@ -26,6 +26,7 @@ bool NoobBook; +bool NoobModeBest = true; int NoobLimit; int failedQueries; @@ -43,7 +44,8 @@ bool ProbeNoob(Position *pos) { puts("info string NoobBook: Querying chessdb.cn for a move..."); // Query dbcn - char *msg_fmt = "GET https://www.chessdb.cn/cdb.php?action=querybest&board=%s\n"; + char *msg_fmt = NoobModeBest ? "GET https://www.chessdb.cn/cdb.php?action=querybest&board=%s\n" + : "GET https://www.chessdb.cn/cdb.php?action=queryall&board=%s\n"; char *hostname = "www.chessdb.cn"; char *response = Query(hostname, msg_fmt, pos); @@ -57,3 +59,12 @@ bool ProbeNoob(Position *pos) { return failedQueries = 0, true; } + +void NoobBookSetMode(const char *str) { + if (!strncmp(str, "best", strlen("best"))) + NoobModeBest = true; + else if (!strncmp(str, "all", strlen("all"))) + NoobModeBest = false; + else + puts("info string NoobBook: Valid modes are 'best' and 'all'"); +} diff --git a/src/noobprobe/noobprobe.h b/src/noobprobe/noobprobe.h index 2329398e..11524d9f 100644 --- a/src/noobprobe/noobprobe.h +++ b/src/noobprobe/noobprobe.h @@ -28,3 +28,4 @@ extern int failedQueries; bool ProbeNoob(Position *pos); +void NoobBookSetMode(const char *str); diff --git a/src/uci.c b/src/uci.c index 2ca92020..658972da 100644 --- a/src/uci.c +++ b/src/uci.c @@ -114,6 +114,7 @@ static void SetOption(char *str) { else if (OptionNameIs("SyzygyPath" )) tb_init(optionValue); else if (OptionNameIs("MultiPV" )) Limits.multiPV = IntValue; else if (OptionNameIs("NoobBookLimit")) NoobLimit = IntValue; + else if (OptionNameIs("NoobBookMode" )) NoobBookSetMode(optionValue); else if (OptionNameIs("NoobBook" )) NoobBook = BooleanValue; else if (OptionNameIs("UCI_Chess960" )) Chess960 = BooleanValue; else if (OptionNameIs("OnlineSyzygy" )) OnlineSyzygy = BooleanValue; @@ -132,6 +133,7 @@ static void Info() { printf("option name MultiPV type spin default 1 min 1 max %d\n", MULTI_PV_MAX); printf("option name UCI_Chess960 type check default false\n"); printf("option name NoobBook type check default false\n"); + printf("option name NoobBookMode string default \n"); printf("option name NoobBookLimit type spin default 0 min 0 max 1000\n"); printf("option name OnlineSyzygy type check default false\n"); printf("uciok\n"); fflush(stdout);