pv.h (empty)

This commit is contained in:
2024-09-02 20:03:08 +02:00
parent 87555f5405
commit b7a5d0fe56
3 changed files with 57 additions and 3 deletions

View File

@@ -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##*/}

View File

@@ -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;
}

53
src/pv.h Normal file
View File

@@ -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 <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
*
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
*
*/
#include <stdio.h>
#include <ctype.h>
#include <brlib.h>
#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;