From 2dbb9fa9b69e49d49cebb1c17559f6fe67600a4d Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Sun, 28 Mar 2021 00:19:05 -0400 Subject: Fix copyright notice in files, and small preemptive optimisation Eventually there'll be a more complicated data generation step than the one we're presently using, so having it in-lined in the loop is wasteful. Ideally also this would be update per ply and we could avoid recalculating it entirely for every query -- though it's probably ``fast enough'' for now. Also, caching is WIP. --- include/cnn1986.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'include/cnn1986.c') diff --git a/include/cnn1986.c b/include/cnn1986.c index dc0e116..9191ec8 100644 --- a/include/cnn1986.c +++ b/include/cnn1986.c @@ -12,7 +12,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with Takwrap. If not, see . + along with ct. If not, see . */ #include "cnn1986.h" @@ -27,8 +27,34 @@ static float dense1[DENSE1_NUM]; static float dense2[DENSE2_NUM]; #define RELU(x) ((x) = ((x)<0)?0:(x)) - float cnn1986_evaluate_black_win(void) { + /* --------------- * + * Generate input * + * --------------- */ + + float cur_board[board_size*board_size][KERN_CHAN]; + for (int y = 0; y < board_size; y++) { + for (int x = 0; x < board_size; x++) { + const int loc = x+y*board_size; + for (int c = 0; c < KERN_CHAN; c++) { // heh, c++ + float lookup = 0; + if (COUNT_AT(loc)>c) { + if (c==0) { + if (STONE_AT(loc) == STONE_STANDING) { + lookup = (colours[loc] & 1) ? +0.25 : -0.25; + } else if (STONE_AT(loc) == STONE_CAPSTONE) { + lookup = (colours[loc] & 1) ? +1.00 : -1.00; + } else { + lookup = (colours[loc] & 1) ? +0.50 : -0.50; + } + } else { + lookup = (colours[loc] & (1<c) { - if (c==0) { - if (STONE_AT(loc) == STONE_STANDING) { - lookup = (colours[loc] & 1) ? +0.25 : -0.25; - } else if (STONE_AT(loc) == STONE_CAPSTONE) { - lookup = (colours[loc] & 1) ? +1.00 : -1.00; - } else { - lookup = (colours[loc] & 1) ? +0.50 : -0.50; - } - } else { - lookup = (colours[loc] & (1<