build: 消除 make 编译警告 (GCC 10.2)

This commit is contained in:
Calcitem 2020-10-24 00:21:12 +08:00
parent d89211f05d
commit bd6396e459
13 changed files with 32 additions and 34 deletions

View File

@ -58,7 +58,7 @@
//#define FIRST_MOVE_STAR_PREFERRED //#define FIRST_MOVE_STAR_PREFERRED
#define TIME_STAT //#define TIME_STAT
//#define CYCLE_STAT //#define CYCLE_STAT
//#define SORT_MOVE_WITHOUT_HUMAN_KNOWLEDGES //#define SORT_MOVE_WITHOUT_HUMAN_KNOWLEDGES

View File

@ -31,7 +31,7 @@ namespace CTSL //Concurrent Thread Safe Library
const K& getKey() const {return key;} const K& getKey() const {return key;}
void setValue(V value_) {value = value_;} void setValue(V value_) {value = value_;}
const V& getValue() const {return value;} V& getValue() {return value;}
void setKey(K key_) {key = key_;} void setKey(K key_) {key = key_;}
#ifndef DISABLE_HASHBUCKET #ifndef DISABLE_HASHBUCKET

View File

@ -159,7 +159,7 @@ CXXFLAGS += -Wall -Wcast-qual -fno-exceptions -std=c++17 $(EXTRACXXFLAGS)
DEPENDFLAGS += -std=c++17 DEPENDFLAGS += -std=c++17
LDFLAGS += $(EXTRALDFLAGS) LDFLAGS += $(EXTRALDFLAGS)
CXXFLAGS += -I../include -I. CXXFLAGS += -Wno-class-memaccess -I../include -I.
ifeq ($(COMP),) ifeq ($(COMP),)
COMP=gcc COMP=gcc

View File

@ -31,6 +31,6 @@ namespace Eval {
std::string trace(Position &pos); std::string trace(Position &pos);
Value evaluate(Position &pos); Value evaluate(Position &pos);
}; }
#endif // #ifndef EVALUATE_H_INCLUDED #endif // #ifndef EVALUATE_H_INCLUDED

View File

@ -81,7 +81,7 @@ namespace CTSL //Concurrent Thread Safe Library
void prefetchValue(const K &key) void prefetchValue(const K &key)
{ {
K hashValue = hashFn(key) & (hashSize - 1); K hashValue = hashFn(key) & (hashSize - 1);
const V *addr = &(hashTable[hashValue].getValue()); V *addr = &(hashTable[hashValue].getValue());
prefetch((void *)addr); prefetch((void *)addr);
} }

View File

@ -96,7 +96,7 @@ struct MoveList
SQ_24, SQ_25, SQ_26, SQ_27, SQ_28, SQ_29, SQ_30, SQ_31, SQ_24, SQ_25, SQ_26, SQ_27, SQ_28, SQ_29, SQ_30, SQ_31,
}; };
inline static Move moveTable[SQUARE_NB][MD_NB] = { {MOVE_NONE} }; inline static Square moveTable[SQUARE_NB][MD_NB] = { {SQ_0} };
private: private:
ExtMove moveList[MAX_MOVES], *last; ExtMove moveList[MAX_MOVES], *last;

View File

@ -142,7 +142,7 @@ public:
Position &pos; Position &pos;
Move ttMove { MOVE_NONE }; Move ttMove { MOVE_NONE };
ExtMove *cur, *endMoves; ExtMove *cur, *endMoves;
ExtMove moves[MAX_MOVES] { MOVE_NONE }; ExtMove moves[MAX_MOVES] { MOVE_NONE, 0 };
int moveCount{ 0 }; int moveCount{ 0 };

View File

@ -24,7 +24,7 @@ GameOptions gameOptions;
void GameOptions::setAutoRestart(bool enabled) void GameOptions::setAutoRestart(bool enabled)
{ {
isAutoRestart = enabled; isAutoRestart = enabled;
}; }
bool GameOptions::getAutoRestart() bool GameOptions::getAutoRestart()
{ {

View File

@ -737,7 +737,7 @@ int Position::set_position(const struct Rule *newRule)
bool Position::reset() bool Position::reset()
{ {
if (phase == PHASE_READY && if (phase == PHASE_READY &&
elapsedSeconds[BLACK] == elapsedSeconds[WHITE] == 0) { elapsedSeconds[BLACK] == 0 && elapsedSeconds[WHITE] == 0) {
return true; return true;
} }
@ -1057,7 +1057,7 @@ bool Position::resign(Color loser)
bool Position::command(const char *cmd) bool Position::command(const char *cmd)
{ {
int ruleIndex; unsigned int ruleIndex;
unsigned t; unsigned t;
int step; int step;
File file1, file2; File file1, file2;
@ -1072,18 +1072,18 @@ bool Position::command(const char *cmd)
return set_position(&RULES[ruleIndex - 1]) >= 0 ? true : false; return set_position(&RULES[ruleIndex - 1]) >= 0 ? true : false;
} }
args = sscanf(cmd, "(%1u,%1u)->(%1u,%1u)", &file1, &rank1, &file2, &rank2); args = sscanf(cmd, "(%1u,%1u)->(%1u,%1u)", (unsigned*)&file1, (unsigned*)&rank1, (unsigned*)&file2, (unsigned*)&rank2);
if (args >= 4) { if (args >= 4) {
return move_piece(file1, rank1, file2, rank2); return move_piece(file1, rank1, file2, rank2);
} }
args = sscanf(cmd, "-(%1u,%1u)", &file1, &rank1); args = sscanf(cmd, "-(%1u,%1u)", (unsigned *)&file1, (unsigned *)&rank1);
if (args >= 2) { if (args >= 2) {
return remove_piece(file1, rank1); return remove_piece(file1, rank1);
} }
args = sscanf(cmd, "(%1u,%1u)", &file1, &rank1); args = sscanf(cmd, "(%1u,%1u)", (unsigned *)&file1, (unsigned *)&rank1);
if (args >= 2) { if (args >= 2) {
return put_piece(file1, rank1); return put_piece(file1, rank1);
} }
@ -1490,7 +1490,6 @@ int Position::in_how_many_mills(Square s, Color c, Square squareSelected)
int Position::add_mills(Square s) int Position::add_mills(Square s)
{ {
uint64_t mill = 0;
int n = 0; int n = 0;
int idx[3], min, temp; int idx[3], min, temp;
Color m = color_on(s); Color m = color_on(s);
@ -1525,13 +1524,6 @@ int Position::add_mills(Square s)
idx[j] = temp; idx[j] = temp;
} }
mill = (static_cast<uint64_t>(board[idx[0]]) << 40)
+ (static_cast<uint64_t>(idx[0]) << 32)
+ (static_cast<uint64_t>(board[idx[1]]) << 24)
+ (static_cast<uint64_t>(idx[1]) << 16)
+ (static_cast<uint64_t>(board[idx[2]]) << 8)
+ static_cast<uint64_t>(idx[2]);
n++; n++;
} }
@ -1744,7 +1736,7 @@ void Position::mirror(vector <string> &cmdlist, bool cmdChange /*= true*/)
} }
if (cmdChange) { if (cmdChange) {
int r1, s1, r2, s2; unsigned r1, s1, r2, s2;
int args = 0; int args = 0;
args = sscanf(cmdline, "(%1u,%1u)->(%1u,%1u)", &r1, &s1, &r2, &s2); args = sscanf(cmdline, "(%1u,%1u)->(%1u,%1u)", &r1, &s1, &r2, &s2);
@ -1869,7 +1861,7 @@ void Position::turn(vector <string> &cmdlist, bool cmdChange /*= true*/)
// 命令行解析 // 命令行解析
if (cmdChange) { if (cmdChange) {
int r1, s1, r2, s2; unsigned r1, s1, r2, s2;
int args = 0; int args = 0;
args = sscanf(cmdline, "(%1u,%1u)->(%1u,%1u)", args = sscanf(cmdline, "(%1u,%1u)->(%1u,%1u)",
@ -2048,7 +2040,7 @@ void Position::rotate(vector <string> &cmdlist, int degrees, bool cmdChange /*=
} }
if (cmdChange) { if (cmdChange) {
int r1, s1, r2, s2; unsigned r1, s1, r2, s2;
int args = 0; int args = 0;
args = sscanf(cmdline, "(%1u,%1u)->(%1u,%1u)", &r1, &s1, &r2, &s2); args = sscanf(cmdline, "(%1u,%1u)->(%1u,%1u)", &r1, &s1, &r2, &s2);

View File

@ -112,7 +112,7 @@ public:
time_t start_timeb() const; time_t start_timeb() const;
void set_start_time(int stimeb); void set_start_time(int stimeb);
Piece *get_board() const; Piece *get_board();
Square current_square() const; Square current_square() const;
enum Phase get_phase() const; enum Phase get_phase() const;
enum Action get_action() const; enum Action get_action() const;
@ -383,7 +383,7 @@ inline bool Position::move_piece(Square from, Square to)
/// Mill Game /// Mill Game
inline Piece *Position::get_board() const inline Piece *Position::get_board()
{ {
return (Piece *)board; return (Piece *)board;
} }

View File

@ -44,6 +44,8 @@ using namespace Search;
Value MTDF(Position *pos, Sanmill::Stack<Position> &ss, Value firstguess, Depth depth, Depth originDepth, Move &bestMove); Value MTDF(Position *pos, Sanmill::Stack<Position> &ss, Value firstguess, Depth depth, Depth originDepth, Move &bestMove);
Value search(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth originDepth, Value alpha, Value beta, Move &bestMove);
namespace namespace
{ {
@ -126,8 +128,10 @@ int Thread::search()
MoveList<LEGAL>::shuffle(); MoveList<LEGAL>::shuffle();
#ifndef MTDF_AI
Value alpha = -VALUE_INFINITE; Value alpha = -VALUE_INFINITE;
Value beta = VALUE_INFINITE; Value beta = VALUE_INFINITE;
#endif
if (gameOptions.getIDSEnabled()) { if (gameOptions.getIDSEnabled()) {
loggerDebug("IDS: "); loggerDebug("IDS: ");
@ -149,7 +153,7 @@ int Thread::search()
#ifdef MTDF_AI #ifdef MTDF_AI
value = MTDF(rootPos, ss, value, i, originDepth, bestMove); value = MTDF(rootPos, ss, value, i, originDepth, bestMove);
#else #else
value = search(pos, ss, i, originDepth, alpha, beta, bestMove); value = search(rootPos, ss, i, originDepth, alpha, beta, bestMove);
#endif #endif
loggerDebug("%d(%d) ", value, value - lastValue); loggerDebug("%d(%d) ", value, value - lastValue);
@ -159,7 +163,7 @@ int Thread::search()
#ifdef TIME_STAT #ifdef TIME_STAT
timeEnd = chrono::steady_clock::now(); timeEnd = chrono::steady_clock::now();
loggerDebug("\nIDS Time: %llus\n", chrono::duration_cast<chrono::seconds>(timeEnd - timeStart).count()); loggerDebug("\nIDS Time: %llds\n", chrono::duration_cast<chrono::seconds>(timeEnd - timeStart).count());
#endif #endif
} }
@ -169,17 +173,19 @@ int Thread::search()
#endif #endif
#endif #endif
#ifndef MTDF_AI
if (gameOptions.getIDSEnabled()) { if (gameOptions.getIDSEnabled()) {
alpha = -VALUE_INFINITE; alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE; beta = VALUE_INFINITE;
} }
#endif
originDepth = d; originDepth = d;
#ifdef MTDF_AI #ifdef MTDF_AI
value = MTDF(rootPos, ss, value, d, originDepth, bestMove); value = MTDF(rootPos, ss, value, d, originDepth, bestMove);
#else #else
value = search(pos, ss, d, originDepth, alpha, beta, bestMove); value = search(rootPos, ss, d, originDepth, alpha, beta, bestMove);
#endif #endif
#ifdef TIME_STAT #ifdef TIME_STAT

View File

@ -35,7 +35,7 @@
#include "config.h" #include "config.h"
#ifdef QT_UI #ifdef QT_UI
#include <QObject> #include <QObject>
#endif QT_UI #endif // QT_UI
/// Thread class keeps together all the thread-related stuff. We use /// Thread class keeps together all the thread-related stuff. We use
/// per-thread pawn and material hash tables so that once we get a /// per-thread pawn and material hash tables so that once we get a

View File

@ -482,7 +482,7 @@ constexpr Square from_sq(Move m)
return static_cast<Square>(m >> 8); return static_cast<Square>(m >> 8);
} }
inline const Square to_sq(Move m) constexpr Square to_sq(Move m)
{ {
if (m < 0) if (m < 0)
m = (Move)-m; m = (Move)-m;
@ -498,7 +498,7 @@ constexpr int from_to(Move m)
return m & 0xFFFF; // TODO return m & 0xFFFF; // TODO
} }
inline const MoveType type_of(Move m) constexpr MoveType type_of(Move m)
{ {
if (m < 0) { if (m < 0) {
return MOVETYPE_REMOVE; return MOVETYPE_REMOVE;
@ -514,12 +514,12 @@ constexpr Move make_move(Square from, Square to)
return Move((from << 8) + to); return Move((from << 8) + to);
} }
inline const Move reverse_move(Move m) constexpr Move reverse_move(Move m)
{ {
return make_move(to_sq(m), from_sq(m)); return make_move(to_sq(m), from_sq(m));
} }
static inline bool is_ok(Move m) constexpr bool is_ok(Move m)
{ {
return from_sq(m) != to_sq(m); // Catch MOVE_NULL and MOVE_NONE return from_sq(m) != to_sq(m); // Catch MOVE_NULL and MOVE_NONE
} }