From b7a5d0fe568c30c267c0d5f19198438cf164cf66 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Mon, 2 Sep 2024 20:03:08 +0200 Subject: [PATCH] pv.h (empty) --- scripts/fetch-all.sh | 3 +++ src/hash.c | 4 +--- src/pv.h | 53 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/pv.h diff --git a/scripts/fetch-all.sh b/scripts/fetch-all.sh index fbfdcb4..98f8409 100755 --- a/scripts/fetch-all.sh +++ b/scripts/fetch-all.sh @@ -29,6 +29,9 @@ readarray -t orig_b < <(git for-each-ref --format='%(refname:short)' \ # bugs: # - We only check local branch existence, not tracking information correctness. # - What about sub-branches ? Like remote/a and remote/a/b not being tracked ? +#for i in `git branch -a | grep remote | grep -v HEAD | grep -v master`; do +# git branch --track ${i#remotes/origin/} $i +#done for remote_b in "${orig_b[@]}"; do short=${remote_b#"$origin"/}; # OR (??): short=${remote_b##*/} diff --git a/src/hash.c b/src/hash.c index 15c489d..15cad2b 100644 --- a/src/hash.c +++ b/src/hash.c @@ -266,10 +266,8 @@ hentry_t *tt_probe(hkey_t key) for (i = 0; i < ENTRIES_PER_BUCKET; ++i) { entry = bucket->entry + i; if (key == entry->key) - break; + return entry; } - if (i < ENTRIES_PER_BUCKET) - return entry; return NULL; } diff --git a/src/pv.h b/src/pv.h new file mode 100644 index 0000000..e06445a --- /dev/null +++ b/src/pv.h @@ -0,0 +1,53 @@ +/* pv.c - Principal variation. + * + * Copyright (C) 2024 Bruno Raoult ("br") + * Licensed under the GNU General Public License v3.0 or later. + * Some rights reserved. See COPYING. + * + * You should have received a copy of the GNU General Public License along with this + * program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include +#include + +#include + +#include "move.h" + +/* + * For PV, we use a triangular structure. The following table is adapted from + * https://www.chessprogramming.org/Triangular_PV-Table. + * + * ply Search maxLengthPV + * Depth + * +--------------------------------------------+ + * 0=root N |N | + * +------------------------------------------+-+ + * 1 N-1 |N-1 | + * +----------------------------------------+-+ + * 2 N-2 |N-2 | + * +----------------------------------------+-+ + * ... / + * +-----+-+ + * N-3 3 |3 | + * +---+-+ + * N-2 2 |2 | + * +-+-+ + * N-1 1 |1| + * +-+ + * + * The offsets will be: + * Depth (=size): 1 2 3 4 5 6 7 ... + * Offset: 0 1 3 6 10 15 21 ... + * + * Off(n) = n * (n - 1) / 2 (direct calc) + * Off(n + 1) = Off(n) + n (calc from previous) + */ + +typedef struct { + move[]; +} foo;