uci: 支持 position fen moves 指令
原来是在 Position::set() 中 th->us = sideToMove; 现在转移到 position() 函数中,以解决 moves 执行指令后再执行 go 卡住的问题。
This commit is contained in:
parent
5c563ce72b
commit
b56990d7c0
|
@ -238,7 +238,6 @@ Position &Position::set(const string &fenStr, Thread *th)
|
|||
// 2. Active color
|
||||
ss >> token;
|
||||
sideToMove = (token == 'b' ? BLACK : WHITE);
|
||||
th->us = sideToMove;
|
||||
|
||||
// 3. Phrase
|
||||
ss >> token;
|
||||
|
|
|
@ -75,6 +75,8 @@ void position(Position *pos, istringstream &is)
|
|||
while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE) {
|
||||
pos->do_move(m);
|
||||
}
|
||||
|
||||
Threads.main()->us = pos->sideToMove;
|
||||
}
|
||||
|
||||
|
||||
|
@ -314,13 +316,10 @@ string UCI::move(Move m)
|
|||
|
||||
|
||||
/// UCI::to_move() converts a string representing a move in coordinate notation
|
||||
/// (g1f3, a7a8q) to the corresponding legal Move, if any.
|
||||
/// to the corresponding legal Move, if any.
|
||||
|
||||
Move UCI::to_move(Position *pos, string &str)
|
||||
{
|
||||
if (str.length() == 5) // Junior could send promotion piece in uppercase
|
||||
str[4] = char(tolower(str[4]));
|
||||
|
||||
for (const auto &m : MoveList<LEGAL>(*pos))
|
||||
if (str == UCI::move(m))
|
||||
return m;
|
||||
|
|
Loading…
Reference in New Issue