From b56990d7c05c607a857bdde78d97af9fb77fad2b Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 22 Nov 2020 10:53:03 +0800 Subject: [PATCH] =?UTF-8?q?uci:=20=E6=94=AF=E6=8C=81=20position=20fen=20mo?= =?UTF-8?q?ves=20=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来是在 Position::set() 中 th->us = sideToMove; 现在转移到 position() 函数中,以解决 moves 执行指令后再执行 go 卡住的问题。 --- src/position.cpp | 1 - src/uci.cpp | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index a5cab31e..1280ce54 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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; diff --git a/src/uci.cpp b/src/uci.cpp index d536b776..6ae0bee6 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -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(*pos)) if (str == UCI::move(m)) return m;