16 std::istream& is, std::ostream& os)
31 std::getline(is, line);
32 const long op_think_time = timer.
read();
34 logger->inputError(
"(stream not available)");
38 if (line ==
"quit" || line ==
"exit")
49 setComputerPlayer(
BLACK,
false);
50 setComputerPlayer(
WHITE,
false);
54 if (line ==
"black") {
55 setComputerPlayer(
BLACK,
true);
56 setComputerPlayer(
WHITE,
false);
59 if (line ==
"white") {
60 setComputerPlayer(
BLACK,
false);
61 setComputerPlayer(
WHITE,
true);
65 const Player turn = state->state().turn();
66 if (! isComputer(turn)) {
67 setComputerPlayer(turn,
true);
68 setComputerPlayer(
alt(turn),
false);
72 if (line ==
"new" || line ==
"beep" || line ==
"random")
74 if (line.find(
"time") == 0 || line.find(
"otime") == 0) {
75 if (line.find(
"time") == 0) {
76 std::istringstream ss(line);
80 setTimeLeft(time/100, time/100);
82 std::cerr << line <<
"\n";
85 if (line.find(
"help") == 0) {
86 std::cerr <<
" 2g7f move a piece from 2g to 2f\n"
87 " P*2d drop a pawn to 2d\n"
88 " undo undo the last move\n"
89 " force human plays both colors\n"
90 " black/white set computer's color\n"
91 " exit/quit exit program\n";
97 if (isdigit(line[0]) || line[1] ==
'*')
101 if (state->isIllegal(op_move))
103 os <<
"Illegal move\n";
104 logger->inputError(line.c_str());
107 const Sennichite result = pushMove(MoveWithComment(op_move), op_think_time);
111 os <<
"White mates!\n";
113 os <<
"Black mates!\n";
115 os <<
"Black mates!\n";
116 setComputerPlayer(
BLACK,
false);
117 setComputerPlayer(
WHITE,
false);
118 logger->endByRepetition(result);
121 const int chess_moves = state->chessMoves();
123 <<
" " << (time_keeper.timeLeft(op_move.
player()) - op_think_time)*100
124 << std::endl << std::flush;
128 std::cerr << line <<
"\n";
129 std::string comment =
"ignored line " + line;
130 logger->writeComment(comment.c_str());
138 const Move best_move = selected.
move;
139 const Player turn = state->state().turn();
141 || (state->isIllegal(best_move)))
143 os << ((
alt(turn) ==
BLACK) ?
"Black" :
"White")
145 logger->resign(turn);
146 setComputerPlayer(
BLACK,
false);
147 setComputerPlayer(
WHITE,
false);
151 const int chess_moves = state->chessMoves();
153 <<
" " << (time_keeper.timeLeft(turn) - my_think_time)*100
154 << std::endl << std::flush;
157 if (! result.isNormal())
160 os <<
"White mates!\n";
162 os <<
"Black mates!\n";
164 os <<
"Black mates!\n";
165 setComputerPlayer(
BLACK,
false);
166 setComputerPlayer(
WHITE,
false);
167 logger->endByRepetition(result);