Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
TerjeKir committed Jan 26, 2024
1 parent 99372c2 commit f024551
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
13 changes: 12 additions & 1 deletion src/noobprobe/noobprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@


bool NoobBook;
bool NoobModeBest = true;
int NoobLimit;
int failedQueries;

Expand All @@ -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);

Expand All @@ -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'");
}
1 change: 1 addition & 0 deletions src/noobprobe/noobprobe.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ extern int failedQueries;


bool ProbeNoob(Position *pos);
void NoobBookSetMode(const char *str);
2 changes: 2 additions & 0 deletions src/uci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <best>\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);
Expand Down

0 comments on commit f024551

Please sign in to comment.