ref: eb7ac7201127ffa3c19cac0e9b8b0b113134256c
parent: cb18a32517a4233240f151a14052977235556169
author: zamfofex <zamfofex@twdb.moe>
date: Wed Jun 4 00:11:14 EDT 2025
make miscellaneous changes
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@
[GCC]: <https://gnu.org/software/gcc/>
[Clang]: <https://clang.llvm.org>
-You can also run your compiler manually if you prefer.
+You may instead run your compiler manually if you prefer.
~~~
# (replace 'cc' with your compiler of choice)
@@ -59,10 +59,10 @@
- **threads** — moonfish uses C11 `<threads.h>` by default
- `make CPPFLAGS=-Dmoonfish_pthreads` to compile with pthreads instead
- `make CPPFLAGS=-Dmoonfish_no_threads` to disable threads altogether
-- **clock/time** — moonfish uses `clock_gettime` by default
- - `make CPPFLAGS=-Dmoonfish_no_clock` to compile with `time(3)` instead
+- **clock/time** — moonfish uses `clock_gettime(3)` by default
+ - `make CPPFLAGS=-Dmoonfish_no_clock` to use `time(3)` instead
- **libraries** — moonfish uses `-pthread` and `-latomic` by default
- - `make LIBPTHREAD= LIBATOMIC=` to disable them (respectively)
+ - `make LIBPTHREAD= LIBATOMIC=` to disable each flag (respectively)
- `make LIBPTHREAD=-lpthread` to replace `-pthread` with `-lpthread`
notes for MacOS
@@ -111,7 +111,7 @@
compiling on 9front
---
-You’ll need [NPE]. After that, you can just compile moonfish and its tools with `mk`. (They have no further dependencies on 9front.)
+You’ll need [NPE]. After that, you should be able to just compile moonfish and some of its tools with `mk`. (They have no further dependencies on 9front.)
[NPE]: <https://git.sr.ht/~ft/npe>
@@ -120,7 +120,7 @@
Clone the repository, then open `moonfish.vcxproj` with Visual Studio.
-- Only the UCI bot will be compiled, not the tools.
+- Only moonfish itself will be compiled, not its tools.
- [MinGW] may be used instead. (This way, the tools may be compiled too.)
- You may use a GUI like [cutechess] to try it.
--- a/main.c
+++ b/main.c
@@ -41,7 +41,7 @@
static void moonfish_log_result(struct moonfish_result *result)
{- printf("info depth %.0f nodes %ld time %ld", log(result->node_count) / log(16), result->node_count, result->time);+ printf("info depth %.0f nodes %ld time %ld", floor(log(result->node_count) / log(16)), result->node_count, result->time);}
static void moonfish_log(struct moonfish_result *result0, void *data)
--- a/makefile
+++ b/makefile
@@ -11,6 +11,7 @@
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
RM = rm -f
+LD = $(CC)
# configurable libraries
LIBM = -lm
@@ -46,7 +47,7 @@
tools/https.o: tools/https.h
moonfish lichess analyse chat perft:
- $(CC) $(LDFLAGS) -o $@ $(.ALLSRC) $($@_libs)
+ $(LD) $(LDFLAGS) -o $@ $(.ALLSRC) $($@_libs)
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
--- a/mkfile
+++ b/mkfile
@@ -14,6 +14,6 @@
chat: chess.$O tools/chat.$O tools/utils.$O tools/https.$O
tools/lichess.$O tools/chat.$O: tools/tools.h tools/https.h
-
tools/utils.$O: tools/tools.h
tools/https.$O: tools/https.h
+search.$O main.$O: threads.h
--- a/search.c
+++ b/search.c
@@ -198,7 +198,7 @@
node->count = child_count;
}
-static float moonfish_confidence(struct moonfish_node *node)
+static double moonfish_confidence(struct moonfish_node *node)
{if (node->visits == 0) return 1e9;
return 1 / (1 + pow(10, node->score / 400.0)) + 2 * sqrt(log(node->parent->visits) / node->visits);
@@ -221,7 +221,7 @@
static struct moonfish_node *moonfish_select(struct moonfish_node *node, struct moonfish_chess *chess)
{struct moonfish_node *next;
- float max_confidence, confidence;
+ double max_confidence, confidence;
int i, count;
for (;;) {@@ -260,7 +260,6 @@
{int i;
short int score, child_score;
- struct moonfish_node *next;
while (node != NULL) {score = node->count == 0 ? 0 : SHRT_MIN;
@@ -268,7 +267,6 @@
child_score = -node->children[i].score;
if (score < child_score) score = child_score;
}
- next = node->parent;
node->score = score;
#ifdef moonfish_no_threads
node->visits++;
@@ -275,7 +273,7 @@
#else
atomic_fetch_add(&node->visits, 1);
#endif
- node = next;
+ node = node->parent;
}
}
--
⑨