aboutsummaryrefslogtreecommitdiff
path: root/include/actions.h
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2021-07-02 12:00:00 -0400
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit640d404b3cf3324aca4424fc3da4806d4562d0e4 (patch)
tree67af41fe52dc7daa2c886b1774367de60b3f817c /include/actions.h
parent0deb42134cb7f0ed6ec809c3de1052ab2dfe2235 (diff)
More towel wringing: re-implemented check_road_colour
Previously check_win would call check_road_colour once for each road colour, and check_road_colour would call a depth-first search (DFS) for each of the two axes. This meant that we were doing (up to) *four* depth-first searches for each call of check_win. I have replaced both axial DFS with the world's worst TM implementation of a connected component generation algorithm backed by the least guaranteed disjoint set data structure. Essentially doing anything about union find correctly is slower than just ... not doing it. Although we lose the asymptotic complexity, in practice we're doing this millions of times per turn, for a fixed board size and that's what matters. All in all, it appears that i've managed to shave about 69ns off check_win, per call -- nice! This amounts to 50ms or so saved at depth 5 per engine move, in one of my test games. Unfortunately nearly 99% of the time is still taken by evaluating the convolutional neural network. It's slow.
Diffstat (limited to 'include/actions.h')
0 files changed, 0 insertions, 0 deletions