refactor: types: 部分 type 改为首字母大写的风格

This commit is contained in:
Calcitem 2020-06-26 20:19:41 +08:00
parent 0f89043a8e
commit 0d230fd993
11 changed files with 28 additions and 28 deletions

View File

@ -155,9 +155,9 @@ void MovePicker::score()
}
#ifdef HOSTORY_HEURISTIC
score_t MovePicker::getHistoryScore(Move move)
Score MovePicker::getHistoryScore(Move move)
{
score_t ret = 0;
Score ret = 0;
if (move < 0) {
#ifndef HOSTORY_HEURISTIC_ACTION_MOVE_ONLY
@ -181,9 +181,9 @@ void MovePicker::setHistoryScore(Move move, Depth depth)
}
#ifdef HOSTORY_HEURISTIC_SCORE_HIGH_WHEN_DEEPER
score_t score = 1 << (32 - depth);
Score score = 1 << (32 - depth);
#else
score_t score = 1 << depth;
Score score = 1 << depth;
#endif
if (move < 0) {

View File

@ -45,11 +45,11 @@ public:
#ifdef HOSTORY_HEURISTIC
// TODO: Fix size
score_t placeHistory[64];
score_t removeHistory[64];
score_t moveHistory[10240];
Score placeHistory[64];
Score removeHistory[64];
Score moveHistory[10240];
score_t getHistoryScore(Move move);
Score getHistoryScore(Move move);
void setHistoryScore(Move move, Depth depth);
void clearHistoryScore();
#endif // HOSTORY_HEURISTIC

View File

@ -208,7 +208,7 @@ player_t Board::locationToPlayer(Square square)
int Board::inHowManyMills(Square square, player_t player, Square squareSelected)
{
int n = 0;
location_t locbak = SQ_0;
Location locbak = SQ_0;
if (player == PLAYER_NOBODY) {
player = locationToPlayer(square);

View File

@ -106,7 +106,7 @@ public:
(locations[square] & 0x10)
(locations[square] & 0x20)
*/
location_t locations[SQUARE_NB]{};
Location locations[SQUARE_NB]{};
Bitboard byTypeBB[PIECE_TYPE_NB];

View File

@ -766,7 +766,7 @@ bool Position::command(const char *cmd)
{
int r;
unsigned t;
step_t s;
Step s;
File r1, r2;
Rank s1, s2;
int args = 0;
@ -1033,7 +1033,7 @@ bool Position::checkGameOverCondition(int8_t updateCmdlist)
int Position::getMobilityDiff(player_t turn, int piecesOnBoard[], bool includeFobidden)
{
// TODO: 处理规则无禁点的情况
location_t *locations = board.locations;
Location *locations = board.locations;
int mobilityBlack = 0;
int mobilityWhite = 0;
int diff = 0;
@ -1190,7 +1190,7 @@ Key Position::updateKey(Square square)
// 0b00 表示空白0b01 = 1 表示先手棋子0b10 = 2 表示后手棋子0b11 = 3 表示禁点
int pieceType = Player::toId(board.locationToPlayer(square));
// TODO: 标准写法应该是如下的写法,但目前这么写也可以工作
//location_t loc = board.locations[square];
//Location loc = board.locations[square];
//int pieceType = loc == 0x0f? 3 : loc >> PLAYER_SHIFT;
// 清除或者放置棋子

View File

@ -91,9 +91,9 @@ public:
bool setPosition(const struct Rule *rule);
// 获取棋盘数据
location_t *getBoardLocations() const
Location *getBoardLocations() const
{
return (location_t *)board.locations;
return (Location *)board.locations;
}
// 获取当前棋子位置点
@ -297,7 +297,7 @@ private:
player_t winner;
// 当前步数
step_t currentStep{};
Step currentStep{};
// 从走子阶段开始或上次吃子起的步数
int moveStep{};

View File

@ -64,7 +64,7 @@ struct Rule
bool allowFlyWhenRemainThreePieces;
// 最大步数,超出判和
step_t maxStepsLedToDraw;
Step maxStepsLedToDraw;
// 包干最长时间超出判负为0则不计时
int maxTimeLedToLose;

View File

@ -17,14 +17,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TYPES_H
#define TYPES_H
#ifndef TYPES_H_INCLUDED
#define TYPES_H_INCLUDED
#include "config.h"
using step_t = uint16_t;
using location_t = uint8_t;
using score_t = uint32_t;
using Step = uint16_t;
using Location = uint8_t;
using Score = uint32_t;
//using Bitboard = uint32_t;
typedef uint32_t Bitboard;
@ -357,4 +357,4 @@ constexpr Move make_move(Square from, Square to)
return Move((from << 8) + to);
}
#endif /* TYPES_H */
#endif // #ifndef TYPES_H_INCLUDED

View File

@ -313,7 +313,7 @@ void GameController::setInvert(bool arg)
#endif // TRAINING_MODE
}
void GameController::setRule(int ruleNo, step_t stepLimited /*= -1*/, int timeLimited /*= -1*/)
void GameController::setRule(int ruleNo, Step stepLimited /*= -1*/, int timeLimited /*= -1*/)
{
// 更新规则,原限时和限步不变
if (ruleNo < 0 || ruleNo >= N_RULES)
@ -1137,7 +1137,7 @@ bool GameController::updateScence()
bool GameController::updateScence(StateInfo &g)
{
#ifndef TRAINING_MODE
const location_t *board = g.position->getBoardLocations();
const Location *board = g.position->getBoardLocations();
QPointF pos;
// game类中的棋子代码

View File

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

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_t>(dStep), dTime);
gameController->setRule(ruleNo, static_cast<Step>(dStep), dTime);
}
}