Compare commits
2 Commits
431baa43d4
...
00fc61020c
Author | SHA1 | Date | |
---|---|---|---|
00fc61020c | |||
06904f8a77 |
@@ -1,53 +1,44 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Fetch all branches from remotes, and track missing ones.
|
||||||
|
#
|
||||||
|
# The value of variable ORIGIN is used for repository origin. If
|
||||||
|
# not set, the default is "origin".
|
||||||
|
|
||||||
origin=origin
|
default_origin=origin
|
||||||
|
|
||||||
declare -a remotes local_b
|
origin=${ORIGIN:-$default_origin}
|
||||||
#declare -A aremotes
|
|
||||||
|
declare -a local_b
|
||||||
declare -A alocal_b
|
declare -A alocal_b
|
||||||
|
|
||||||
# get remotes list
|
|
||||||
readarray -t remotes < <(git remote)
|
|
||||||
|
|
||||||
# fetch all remotes
|
# fetch all remotes
|
||||||
git fetch --all
|
git fetch --all --tags
|
||||||
|
|
||||||
# fill associative array with remote
|
# get local branches, and build reverse associative array
|
||||||
#for remote in "${remotes[@]}"; do
|
|
||||||
# aremotes["$remote"]=1
|
|
||||||
# echo doing git fetch -a "$remote"
|
|
||||||
#done
|
|
||||||
|
|
||||||
# get local branches
|
|
||||||
readarray -t local_b < <(git for-each-ref --format='%(refname:short)' refs/heads/)
|
readarray -t local_b < <(git for-each-ref --format='%(refname:short)' refs/heads/)
|
||||||
|
|
||||||
# build local ref array
|
|
||||||
for ref in "${local_b[@]}"; do
|
for ref in "${local_b[@]}"; do
|
||||||
alocal_b[$ref]=1
|
alocal_b[$ref]=1
|
||||||
done
|
done
|
||||||
|
|
||||||
# get origin branches
|
# get "origin" branches
|
||||||
readarray -t orig_b < <(git for-each-ref --format='%(refname:short)' \
|
readarray -t orig_b < <(git for-each-ref --format='%(refname:short)' \
|
||||||
refs/remotes/"$origin"/)
|
refs/remotes/"$origin"/)
|
||||||
|
|
||||||
declare -p remotes
|
# find-out missing local branches and track them.
|
||||||
declare -p local_b orig_b
|
# bugs:
|
||||||
|
# - We only check local branch existence, not tracking information correctness.
|
||||||
# find-out missing local branches and track them
|
# - What about sub-branches ? Like remote/a and remote/a/b not being tracked ?
|
||||||
for remote_b in "${orig_b[@]}"; do
|
for remote_b in "${orig_b[@]}"; do
|
||||||
short=${remote_b#"$origin"/};
|
short=${remote_b#"$origin"/};
|
||||||
#echo "$remote_b -> $short ${alocal_b[$short]}"
|
# OR (??): short=${remote_b##*/}
|
||||||
|
|
||||||
if ! [[ -v alocal_b[$short] ]]; then
|
if ! [[ -v alocal_b[$short] ]]; then
|
||||||
echo git branch --track "$short" "$remote_b"
|
printf "local branch %s set to track %s.\n" "$short" "$remote_b"
|
||||||
# echo git branch: "$remote_b"
|
git branch --track "$short" "$remote_b"
|
||||||
|
else
|
||||||
|
printf "skipping %s.\n" "$remote_b"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo git pull --all
|
git pull -a
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#git remote | xargs -n 1 git fetch -a
|
|
||||||
|
@@ -66,9 +66,9 @@ void zobrist_init(void)
|
|||||||
*
|
*
|
||||||
* @return: @pos Zobrist key
|
* @return: @pos Zobrist key
|
||||||
*/
|
*/
|
||||||
key_t zobrist_calc(pos_t *pos)
|
hkey_t zobrist_calc(pos_t *pos)
|
||||||
{
|
{
|
||||||
key_t key = 0;
|
hkey_t key = 0;
|
||||||
|
|
||||||
if (pos->turn == BLACK)
|
if (pos->turn == BLACK)
|
||||||
key ^= zobrist_turn;
|
key ^= zobrist_turn;
|
||||||
|
14
src/hash.h
14
src/hash.h
@@ -24,7 +24,7 @@
|
|||||||
#define HASH_SIZE_MIN 4
|
#define HASH_SIZE_MIN 4
|
||||||
#define HASH_SIZE_MAX 32768 /* 32Gb */
|
#define HASH_SIZE_MAX 32768 /* 32Gb */
|
||||||
|
|
||||||
#define key_t u64 /* cannot use typedef for key_t */
|
typedef u64 hkey_t; /* cannot use typedef for key_t */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hentry_t: hashtable bucket.
|
* hentry_t: hashtable bucket.
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
* 16 bytes in future, it should be updated to be exactly 32 bytes.
|
* 16 bytes in future, it should be updated to be exactly 32 bytes.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
key_t key; /* zobrist */
|
hkey_t key; /* zobrist */
|
||||||
union {
|
union {
|
||||||
u64 data;
|
u64 data;
|
||||||
struct {
|
struct {
|
||||||
@@ -81,15 +81,15 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
#define EP_ZOBRIST_IDX(ep) ( ( (ep) >> 3 ) | sq_file(ep) )
|
#define EP_ZOBRIST_IDX(ep) ( ( (ep) >> 3 ) | sq_file(ep) )
|
||||||
|
|
||||||
extern key_t zobrist_pieces[16][64];
|
extern hkey_t zobrist_pieces[16][64];
|
||||||
extern key_t zobrist_castling[4 * 4 + 1];
|
extern hkey_t zobrist_castling[4 * 4 + 1];
|
||||||
extern key_t zobrist_turn; /* for black, XOR each ply */
|
extern hkey_t zobrist_turn; /* for black, XOR each ply */
|
||||||
extern key_t zobrist_ep[9]; /* 0-7: ep file, 8: SQUARE_NONE */
|
extern hkey_t zobrist_ep[9]; /* 0-7: ep file, 8: SQUARE_NONE */
|
||||||
|
|
||||||
extern hasht_t hash_tt; /* main transposition table */
|
extern hasht_t hash_tt; /* main transposition table */
|
||||||
|
|
||||||
void zobrist_init(void);
|
void zobrist_init(void);
|
||||||
key_t zobrist_calc(pos_t *pos);
|
hkey_t zobrist_calc(pos_t *pos);
|
||||||
|
|
||||||
#ifdef ZOBRIST_VERIFY
|
#ifdef ZOBRIST_VERIFY
|
||||||
bool zobrist_verify(pos_t *pos);
|
bool zobrist_verify(pos_t *pos);
|
||||||
|
@@ -61,7 +61,7 @@ pos_t *move_do(pos_t *pos, const move_t move) //, state_t *state)
|
|||||||
piece_type_t ptype = PIECE(piece);
|
piece_type_t ptype = PIECE(piece);
|
||||||
piece_t new_piece = piece;
|
piece_t new_piece = piece;
|
||||||
int up = sq_up(us);
|
int up = sq_up(us);
|
||||||
key_t key = pos->key;
|
hkey_t key = pos->key;
|
||||||
|
|
||||||
/* update key: switch turn, reset castling and ep */
|
/* update key: switch turn, reset castling and ep */
|
||||||
key ^= zobrist_turn;
|
key ^= zobrist_turn;
|
||||||
@@ -146,7 +146,7 @@ pos_t *move_do(pos_t *pos, const move_t move) //, state_t *state)
|
|||||||
pos->castle = clr_oo(pos->castle, them);
|
pos->castle = clr_oo(pos->castle, them);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update castle key */
|
/* update castling rights key */
|
||||||
key ^= zobrist_castling[pos->castle];
|
key ^= zobrist_castling[pos->castle];
|
||||||
|
|
||||||
pos->key = key;
|
pos->key = key;
|
||||||
@@ -168,7 +168,7 @@ pos_t *move_do2(pos_t *pos, const move_t move, state_t *state)
|
|||||||
piece_type_t ptype = PIECE(piece);
|
piece_type_t ptype = PIECE(piece);
|
||||||
piece_t new_piece = piece;
|
piece_t new_piece = piece;
|
||||||
int up = sq_up(us);
|
int up = sq_up(us);
|
||||||
key_t key = pos->key;
|
hkey_t key = pos->key;
|
||||||
|
|
||||||
*state = pos->state; /* save irreversible changes */
|
*state = pos->state; /* save irreversible changes */
|
||||||
|
|
||||||
|
@@ -28,6 +28,13 @@
|
|||||||
#include "move.h"
|
#include "move.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
|
#define REPEAT_SIZE 1024
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
hkey_t key[REPEAT_SIZE];
|
||||||
|
int moves;
|
||||||
|
} repeat_t;
|
||||||
|
|
||||||
typedef struct __pos_s {
|
typedef struct __pos_s {
|
||||||
u64 node_count; /* evaluated nodes */
|
u64 node_count; /* evaluated nodes */
|
||||||
int turn; /* WHITE or BLACK */
|
int turn; /* WHITE or BLACK */
|
||||||
@@ -43,7 +50,7 @@ typedef struct __pos_s {
|
|||||||
* This allows a memcpy on this data (to save/restore position state).
|
* This allows a memcpy on this data (to save/restore position state).
|
||||||
*/
|
*/
|
||||||
struct_group_tagged(state_s, state,
|
struct_group_tagged(state_s, state,
|
||||||
key_t key;
|
hkey_t key;
|
||||||
square_t en_passant;
|
square_t en_passant;
|
||||||
castle_rights_t castle;
|
castle_rights_t castle;
|
||||||
int clock_50;
|
int clock_50;
|
||||||
@@ -57,6 +64,7 @@ typedef struct __pos_s {
|
|||||||
piece_t board[BOARDSIZE];
|
piece_t board[BOARDSIZE];
|
||||||
bitboard_t bb[2][PIECE_TYPE_MAX]; /* bb[0][PAWN], bb[1][ALL_PIECES] */
|
bitboard_t bb[2][PIECE_TYPE_MAX]; /* bb[0][PAWN], bb[1][ALL_PIECES] */
|
||||||
square_t king[2]; /* dup with bb, faster retrieval */
|
square_t king[2]; /* dup with bb, faster retrieval */
|
||||||
|
repeat_t repeat; /* for repetition detection */
|
||||||
} pos_t;
|
} pos_t;
|
||||||
|
|
||||||
typedef struct state_s state_t;
|
typedef struct state_s state_t;
|
||||||
|
Reference in New Issue
Block a user