types: 移除 Step 类型

原为 uint16_t, 改为 int。
This commit is contained in:
Calcitem 2020-09-24 01:10:14 +08:00
parent c921bafbf6
commit af062f0ebd
7 changed files with 8 additions and 31 deletions

View File

@ -37,8 +37,8 @@ double to_cp(Value v)
std::ostream &operator<<(std::ostream &os, Score s)
{
os << std::setw(5) << to_cp(mg_value(s)) << " "
<< std::setw(5) << to_cp(eg_value(s));
os << std::setw(5) << "" << " "
<< std::setw(5) << "";
return os;
}
}

View File

@ -892,7 +892,7 @@ bool Position::command(const char *cmd)
{
int ruleIndex;
unsigned t;
Step step;
int step;
File file1, file2;
Rank rank1, rank2;
int args = 0;

View File

@ -37,7 +37,7 @@ struct Rule
bool isBlackLosebutNotDrawWhenBoardFull;
bool isLoseButNotChangeSideWhenNoWay;
bool allowFlyWhenRemainThreePieces;
Step maxStepsLedToDraw;
int maxStepsLedToDraw;
};
#define N_RULES 5

View File

@ -99,7 +99,6 @@ constexpr bool Is64Bit = true;
constexpr bool Is64Bit = false;
#endif
using Step = uint16_t;
using Score = uint32_t;
//using Bitboard = uint32_t;
typedef uint32_t Bitboard;
@ -360,28 +359,6 @@ constexpr Score make_score(int mg, int eg)
return Score((int)((unsigned int)eg << 16) + mg);
}
/// Extracting the signed lower and upper 16 bits is not so trivial because
/// according to the standard a simple cast to short is implementation defined
/// and so is a right shift of a signed integer.
inline Value eg_value(Score s)
{
union
{
uint16_t u; int16_t s;
} eg = { uint16_t(unsigned(s + 0x8000) >> 16) };
return Value(eg.s);
}
inline Value mg_value(Score s)
{
union
{
uint16_t u; int16_t s;
} mg = { uint16_t(unsigned(s)) };
return Value(mg.s);
}
// TODO End
#define ENABLE_BASE_OPERATORS_ON(T) \
constexpr T operator+(T d1, T d2) { return T(int(d1) + int(d2)); } \
constexpr T operator-(T d1, T d2) { return T(int(d1) - int(d2)); } \

View File

@ -325,7 +325,7 @@ void GameController::setInvert(bool arg)
#endif // TRAINING_MODE
}
void GameController::setRule(int ruleNo, Step stepLimited /*= -1*/, int timeLimited /*= -1*/)
void GameController::setRule(int ruleNo, int stepLimited /*= -1*/, int timeLimited /*= -1*/)
{
// 更新规则,原限时和限步不变
if (ruleNo < 0 || ruleNo >= N_RULES)

View File

@ -181,7 +181,7 @@ signals:
public slots:
// 设置规则
void setRule(int ruleNo, Step stepLimited = std::numeric_limits<uint16_t>::max(), int timeLimited = -1);
void setRule(int ruleNo, int stepLimited = std::numeric_limits<uint16_t>::max(), int timeLimited = -1);
// 游戏开始
void gameStart();
@ -440,7 +440,7 @@ private:
int timeLimit;
// 规则限步数
Step stepsLimit;
int stepsLimit;
// 玩家剩余时间(秒)
time_t remainingTime[COLOR_NB];

View File

@ -551,7 +551,7 @@ void MillGameWindow::on_actionLimited_T_triggered()
int dTime = comboBox_time->currentData().toInt();
if (gStep != dStep || gTime != dTime) {
// 重置游戏规则
gameController->setRule(ruleNo, static_cast<Step>(dStep), dTime);
gameController->setRule(ruleNo, static_cast<int>(dStep), dTime);
}
}