All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cuiClient.cc
Go to the documentation of this file.
1 /* cuiClient.cc
2  */
7 
10  CsaLogger *l, std::istream& i, std::ostream& o)
11  : GameManager(black, white, l), is(i), os(o), stop_by_outside(0)
12 {
13 }
14 
17 {
18 }
19 
21 CuiClient::run(const char *black, const char *white)
22 {
23  logger->init(black, white, state->state());
24  run();
25 }
26 
29 {
30  try
31  {
32  logger->writeComment("game start");
33  while (1)
34  {
35  while (! isComputer(state->state().turn()))
36  {
37  while (readAndProcessCommand())
38  ;
39  }
40  int seconds=0;
41  MoveWithComment best_move;
42  if (! stop_by_outside)
43  {
44  best_move = computeMove(seconds);
45  }
46  else
47  {
48  best_move = MoveWithComment(Move::INVALID());
49  logger->writeComment("forced resign");
50  }
51  processComputerMove(best_move, seconds);
52  }
53  }
54  catch (EndGame&)
55  {
56  logger->writeComment("game end");
57  }
58  return;
59 }
60 
61 
62 /* ------------------------------------------------------------------------- */
63 // ;;; Local Variables:
64 // ;;; mode:c++
65 // ;;; c-basic-offset:2
66 // ;;; End: