cuiClient.cc
Go to the documentation of this file.
00001 /* cuiClient.cc
00002  */
00003 #include "osl/game_playing/cuiClient.h"
00004 #include "osl/game_playing/gameState.h"
00005 #include "osl/game_playing/csaLogger.h"
00006 #include "osl/search/moveWithComment.h"
00007 
00008 osl::game_playing::
00009 CuiClient::CuiClient(ComputerPlayer *black, ComputerPlayer *white,
00010                      CsaLogger *l, std::istream& i, std::ostream& o)
00011   : GameManager(black, white, l), is(i), os(o), stop_by_outside(0)
00012 {
00013 }
00014 
00015 osl::game_playing::
00016 CuiClient::~CuiClient()
00017 {
00018 }
00019 
00020 void osl::game_playing::
00021 CuiClient::run(const char *black, const char *white)
00022 {
00023   logger->init(black, white, state->state());
00024   run();
00025 }
00026 
00027 void osl::game_playing::
00028 CuiClient::run()
00029 {
00030   try
00031   {
00032     logger->writeComment("game start");
00033     while (1)
00034     {
00035       while (! isComputer(state->state().turn()))
00036       {
00037         while (readAndProcessCommand())
00038           ;
00039       }
00040       int seconds=0;
00041       MoveWithComment best_move;
00042       if (! stop_by_outside)
00043       {
00044         best_move = computeMove(seconds);
00045       }
00046       else
00047       {
00048         best_move = MoveWithComment(Move::INVALID());
00049         logger->writeComment("forced resign");
00050       }
00051       processComputerMove(best_move, seconds);
00052     }
00053   }
00054   catch (EndGame&)
00055   {
00056     logger->writeComment("game end");
00057   }
00058   return;
00059 }
00060 
00061 
00062 /* ------------------------------------------------------------------------- */
00063 // ;;; Local Variables:
00064 // ;;; mode:c++
00065 // ;;; c-basic-offset:2
00066 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines