parent
c921bafbf6
commit
af062f0ebd
|
@ -37,8 +37,8 @@ double to_cp(Value v)
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, Score s)
|
std::ostream &operator<<(std::ostream &os, Score s)
|
||||||
{
|
{
|
||||||
os << std::setw(5) << to_cp(mg_value(s)) << " "
|
os << std::setw(5) << "" << " "
|
||||||
<< std::setw(5) << to_cp(eg_value(s));
|
<< std::setw(5) << "";
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -892,7 +892,7 @@ bool Position::command(const char *cmd)
|
||||||
{
|
{
|
||||||
int ruleIndex;
|
int ruleIndex;
|
||||||
unsigned t;
|
unsigned t;
|
||||||
Step step;
|
int step;
|
||||||
File file1, file2;
|
File file1, file2;
|
||||||
Rank rank1, rank2;
|
Rank rank1, rank2;
|
||||||
int args = 0;
|
int args = 0;
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct Rule
|
||||||
bool isBlackLosebutNotDrawWhenBoardFull;
|
bool isBlackLosebutNotDrawWhenBoardFull;
|
||||||
bool isLoseButNotChangeSideWhenNoWay;
|
bool isLoseButNotChangeSideWhenNoWay;
|
||||||
bool allowFlyWhenRemainThreePieces;
|
bool allowFlyWhenRemainThreePieces;
|
||||||
Step maxStepsLedToDraw;
|
int maxStepsLedToDraw;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define N_RULES 5
|
#define N_RULES 5
|
||||||
|
|
23
src/types.h
23
src/types.h
|
@ -99,7 +99,6 @@ constexpr bool Is64Bit = true;
|
||||||
constexpr bool Is64Bit = false;
|
constexpr bool Is64Bit = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using Step = uint16_t;
|
|
||||||
using Score = uint32_t;
|
using Score = uint32_t;
|
||||||
//using Bitboard = uint32_t;
|
//using Bitboard = uint32_t;
|
||||||
typedef uint32_t Bitboard;
|
typedef uint32_t Bitboard;
|
||||||
|
@ -360,28 +359,6 @@ constexpr Score make_score(int mg, int eg)
|
||||||
return Score((int)((unsigned int)eg << 16) + mg);
|
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) \
|
#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)); } \
|
||||||
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)); } \
|
||||||
|
|
|
@ -325,7 +325,7 @@ void GameController::setInvert(bool arg)
|
||||||
#endif // TRAINING_MODE
|
#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)
|
if (ruleNo < 0 || ruleNo >= N_RULES)
|
||||||
|
|
|
@ -181,7 +181,7 @@ signals:
|
||||||
public slots:
|
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();
|
void gameStart();
|
||||||
|
@ -440,7 +440,7 @@ private:
|
||||||
int timeLimit;
|
int timeLimit;
|
||||||
|
|
||||||
// 规则限步数
|
// 规则限步数
|
||||||
Step stepsLimit;
|
int stepsLimit;
|
||||||
|
|
||||||
// 玩家剩余时间(秒)
|
// 玩家剩余时间(秒)
|
||||||
time_t remainingTime[COLOR_NB];
|
time_t remainingTime[COLOR_NB];
|
||||||
|
|
|
@ -551,7 +551,7 @@ void MillGameWindow::on_actionLimited_T_triggered()
|
||||||
int dTime = comboBox_time->currentData().toInt();
|
int dTime = comboBox_time->currentData().toInt();
|
||||||
if (gStep != dStep || gTime != dTime) {
|
if (gStep != dStep || gTime != dTime) {
|
||||||
// 重置游戏规则
|
// 重置游戏规则
|
||||||
gameController->setRule(ruleNo, static_cast<Step>(dStep), dTime);
|
gameController->setRule(ruleNo, static_cast<int>(dStep), dTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue