00001 /* computerPlayer.cc 00002 */ 00003 #include "osl/game_playing/computerPlayer.h" 00004 #include "osl/game_playing/gameState.h" 00005 #include "osl/game_playing/openingBookTracer.h" 00006 #include "osl/move_generator/legalMoves.h" 00007 #include "osl/container/moveVector.h" 00008 #include "osl/misc/random.h" 00009 00010 osl::game_playing:: 00011 ComputerPlayer::~ComputerPlayer() 00012 { 00013 } 00014 00015 bool osl::game_playing:: 00016 ComputerPlayer::isReasonableMove(const GameState&, Move, int) 00017 { 00018 return true; 00019 } 00020 00021 void osl::game_playing:: 00022 ComputerPlayer::allowSpeculativeSearch(bool value) 00023 { 00024 speculative_search_allowed = value; 00025 } 00026 00027 /* ------------------------------------------------------------------------- */ 00028 00029 osl::game_playing:: 00030 ResignPlayer::~ResignPlayer() 00031 { 00032 } 00033 00034 void osl::game_playing:: 00035 ResignPlayer::pushMove(Move) 00036 { 00037 } 00038 void osl::game_playing:: 00039 ResignPlayer::popMove() 00040 { 00041 } 00042 const osl::game_playing::MoveWithComment osl::game_playing:: 00043 ResignPlayer::selectBestMove(const GameState&, int, int) 00044 { 00045 return MoveWithComment(Move::INVALID()); 00046 } 00047 00048 /* ------------------------------------------------------------------------- */ 00049 00050 osl::game_playing:: 00051 RandomPlayer::~RandomPlayer() 00052 { 00053 } 00054 00055 void osl::game_playing:: 00056 RandomPlayer::pushMove(Move) 00057 { 00058 } 00059 void osl::game_playing:: 00060 RandomPlayer::popMove() 00061 { 00062 } 00063 const osl::game_playing::MoveWithComment osl::game_playing:: 00064 RandomPlayer::selectBestMove(const GameState& state, int, int) 00065 { 00066 MoveVector moves; 00067 move_generator::LegalMoves::generate(state.state(), moves); 00068 if (moves.empty()) 00069 return game_playing::MoveWithComment(Move::INVALID()); 00070 return game_playing::MoveWithComment(moves[time_seeded_random() % moves.size()]); 00071 } 00072 00073 /* ------------------------------------------------------------------------- */ 00074 // ;;; Local Variables: 00075 // ;;; mode:c++ 00076 // ;;; c-basic-offset:2 00077 // ;;; End: