1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

use std::sort() (#640)

No functional change.
This commit is contained in:
lucasart 2016-04-18 21:13:03 +08:00 committed by Marco Costalba
parent 994f9a7a35
commit 8609c4ece4
2 changed files with 6 additions and 12 deletions

View file

@ -27,8 +27,6 @@
#define TBMAX_PAWN 256 #define TBMAX_PAWN 256
#define HSHMAX 5 #define HSHMAX 5
static Mutex TB_mutex;
static std::vector<std::string> paths; static std::vector<std::string> paths;
static int TBnum_piece, TBnum_pawn; static int TBnum_piece, TBnum_pawn;
@ -593,7 +591,7 @@ void Tablebases::init(const std::string& path)
static uint64_t encode_piece(TBEntry_piece *ptr, uint8_t *norm, int *pos, int *factor) static uint64_t encode_piece(TBEntry_piece *ptr, uint8_t *norm, int *pos, int *factor)
{ {
uint64_t idx; uint64_t idx;
int i, j, k, m, l, p; int i, j, m, l, p;
int n = ptr->num; int n = ptr->num;
if (pos[0] & 4) { if (pos[0] & 4) {
@ -660,9 +658,7 @@ static uint64_t encode_piece(TBEntry_piece *ptr, uint8_t *norm, int *pos, int *f
for (; i < n;) { for (; i < n;) {
int t = norm[i]; int t = norm[i];
for (j = i; j < i + t; j++) std::sort(&pos[i], &pos[i + t]);
for (k = j + 1; k < i + t; k++)
if (pos[j] > pos[k]) std::swap(pos[j], pos[k]);
int s = 0; int s = 0;
@ -722,9 +718,7 @@ static uint64_t encode_pawn(TBEntry_pawn *ptr, uint8_t *norm, int *pos, int *fac
t = i + ptr->pawns[1]; t = i + ptr->pawns[1];
if (t > i) { if (t > i) {
for (j = i; j < t; j++) std::sort(&pos[i], &pos[t]);
for (k = j + 1; k < t; k++)
if (pos[j] > pos[k]) std::swap(pos[j], pos[k]);
s = 0; s = 0;
@ -744,9 +738,7 @@ static uint64_t encode_pawn(TBEntry_pawn *ptr, uint8_t *norm, int *pos, int *fac
for (; i < n;) { for (; i < n;) {
t = norm[i]; t = norm[i];
for (j = i; j < i + t; j++) std::sort(&pos[i], &pos[i + t]);
for (k = j + 1; k < i + t; k++)
if (pos[j] > pos[k]) std::swap(pos[j], pos[k]);
s = 0; s = 0;

View file

@ -23,6 +23,8 @@ namespace Zobrist {
extern Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB]; extern Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
} }
static Mutex TB_mutex;
int Tablebases::MaxCardinality = 0; int Tablebases::MaxCardinality = 0;
// Given a position with 6 or fewer pieces, produce a text string // Given a position with 6 or fewer pieces, produce a text string