00001
00002
00003 #include "osl/game_playing/alphaBetaPlayer.h"
00004 #include "osl/game_playing/searchPlayer.tcc"
00005 #include "osl/search/alphaBeta2.h"
00006 #include "osl/search/simpleHashTable.h"
00007 #include "osl/eval/progressEval.h"
00008 #include "osl/eval/pieceEval.h"
00009 #include "osl/category/standardMoveGenerator.h"
00010 #include <iostream>
00011
00012 osl::game_playing::
00013 AlphaBeta2Player::AlphaBeta2Player()
00014 {
00015 }
00016
00017 osl::game_playing::
00018 AlphaBeta2Player::~AlphaBeta2Player()
00019 {
00020 }
00021
00022 osl::game_playing::ComputerPlayer* osl::game_playing::
00023 AlphaBeta2Player::clone() const
00024 {
00025 return cloneIt(*this);
00026 }
00027
00028 const osl::game_playing::MoveWithComment osl::game_playing::
00029 AlphaBeta2Player::searchWithSecondsForThisMove(const GameState& gs, int seconds)
00030 {
00031 const int consumed = setUpTable(gs, pawnValueOfTurn<AlphaBeta2>(gs.state().getTurn()));
00032 if (seconds > 0)
00033 seconds = std::max(1, seconds-consumed);
00034 searcher.reset();
00035 try
00036 {
00037 searcher.reset(new AlphaBeta2(gs.state(), *checkmate_ptr, table_ptr.get(),
00038 *recorder_ptr));
00039 }
00040 catch (std::bad_alloc&)
00041 {
00042 std::cerr << "panic. allocation of AlphaBeta2 failed\n";
00043 }
00044 return SearchPlayer::search<AlphaBeta2>(gs, seconds);
00045 }
00046
00047 bool osl::game_playing::
00048 AlphaBeta2Player::isReasonableMove(const GameState& gs,
00049 Move move, int pawn_sacrifice)
00050 {
00051 setUpTable(gs, pawnValueOfTurn<AlphaBeta2>(gs.state().getTurn()));
00052 AlphaBeta2 searcher(gs.state(), *checkmate_ptr, table_ptr.get(),
00053 *recorder_ptr);
00054 return SearchPlayer::isReasonableMoveBySearch(searcher, move, pawn_sacrifice);
00055 }
00056
00057
00058
00059
00060
00061