-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Handle *some* out-of-spec behaviour explicitly #4563
Changes from 7 commits
4f4cc84
7b40044
c606f7d
a44292c
c968e3b
f39ca49
e1a298e
d341695
c79202c
0c19465
fb1a7f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,8 +71,16 @@ namespace { | |
pos.set(fen, Options["UCI_Chess960"], &states->back(), Threads.main()); | ||
|
||
// Parse the move list, if any | ||
while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE) | ||
while (is >> token) | ||
{ | ||
if (pos.state()->rule50 > 99) | ||
UCI::critical_error("Invalid move. Draw by rule50 reached."); | ||
|
||
m = UCI::to_move(pos, token); | ||
|
||
if (m == MOVE_NONE) | ||
UCI::critical_error("Invalid moves. Illegal move."); | ||
|
||
states->emplace_back(); | ||
pos.do_move(m, states->back()); | ||
} | ||
|
@@ -395,4 +403,12 @@ Move UCI::to_move(const Position& pos, string& str) { | |
return MOVE_NONE; | ||
} | ||
|
||
void UCI::critical_error(const std::string& message) { | ||
// Ideally we would report the error and continue, but UCI does not define such a situation nor | ||
// gives any guarantees as to the program's behaviour for the user to rely on, | ||
// so the safest option is to terminate. | ||
sync_cout << "info string CRITICAL ERROR: " << message << '\n' << sync_endl; | ||
std::terminate(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exiting is an appropriate action here, but I don’t think |
||
} | ||
|
||
} // namespace Stockfish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite unnecessary IMO, rule50 count doesn't really affect gameplay, and user can easily artifically bypass it anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the 50-move rule and 75-move rule do apply in over-the-board play, they do not apply for certain purposes in endgame theory. In particular, endgame tablebases will allow one to step through a forced with that takes far longer, and this would (presulably) result in a larger count here. Instead of refusing to import the FEN, I think it would be better for Stockfish to clamp rule50 to 150.