Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HandicapPlayer Class Reference

Player using Handicap to generate moves. More...

#include <HandicapPlayer.hpp>

Inheritance diagram for HandicapPlayer:
BenzenePlayer HexPlayer

List of all members.

Public Member Functions

 HandicapPlayer (ICEngine *ice)
virtual ~HandicapPlayer ()
std::string Name () const
 returns "handicap".
HexPoint GenMove (const HexState &state, const Game &game, HexBoard &brd, double maxTime, double &score)
 Generates a move from this board position.
bool SearchSingleton () const
 Search states with only a single move?
void SetSearchSingleton (bool flag)
 See SetSearchSingleton().

Protected Member Functions

virtual HexPoint Search (HexBoard &brd, const Game &game_state, HexColor color, const bitset_t &consider, double max_time, double &score)
 Generates a move in the given gamestate using handicap strategy.
bool FillinCausedWin () const
virtual HexPoint Search (const HexState &state, const Game &game, HexBoard &brd, const bitset_t &consider, double maxTime, double &score)=0
 Generates a move in the given gamestate.

Protected Attributes

bool m_fillinCausedWin
HexColor m_fillinWinner

Private Member Functions

void buildResponseMap (const StoneBoard &brd)
 Build the mapping of what the mirror of each HexPoint is.
void makeMiai (HexPoint p1, HexPoint p2)
 Takes two HexPoints and maps them to each other.
void threeToOne (const StoneBoard &brd, HexPoint dest, HexPoint p1, HexPoint p2, HexPoint p3)
 Takes four HexPoints and maps p1, p2, and p3 to dest unless p1, p2, and/or p3 are already occupied, in which case there are a number of special cases.

Private Attributes

ICEnginem_ice
bool m_assume_added_stones
PointToPoint m_responseMap
int m_width

Detailed Description

Player using Handicap to generate moves.

Note:
This player is not used.
Todo:
CLEANUP!

Definition at line 21 of file HandicapPlayer.hpp.


Constructor & Destructor Documentation

HandicapPlayer::HandicapPlayer ( ICEngine ice  )  [explicit]

Definition at line 14 of file HandicapPlayer.cpp.

References LogFine().

HandicapPlayer::~HandicapPlayer (  )  [virtual]

Definition at line 22 of file HandicapPlayer.cpp.


Member Function Documentation

void HandicapPlayer::buildResponseMap ( const StoneBoard brd  )  [private]
bool BenzenePlayer::FillinCausedWin (  )  const [inline, protected, inherited]

Definition at line 86 of file BenzenePlayer.hpp.

References BenzenePlayer::m_fillinCausedWin.

Referenced by PerfectPlayer::Search().

HexPoint BenzenePlayer::GenMove ( const HexState state,
const Game game,
HexBoard brd,
double  maxTime,
double &  score 
) [virtual, inherited]

Generates a move from this board position.

If the game is already over (somebody has won), returns RESIGN.

Derived Benzene players that use different search algorithms should not extend this method, but the protected virtual method Search() below.

If state is terminal (game over, vc/fill-in win/loss), returns "appropriate" move. Otherwise, calls Search().

Bug:
Subtract time spent to here from max_time after each step.

Implements HexPlayer.

Definition at line 27 of file BenzenePlayer.cpp.

References BenzenePlayer::CheckEndgame(), BenzenePlayer::InitSearch(), INVALID_POINT, LogInfo(), BenzenePlayer::Search(), and HexState::ToPlay().

Referenced by MoHexEngine::DoSearch(), WolveEngine::GenMove(), PlayAndSolve::PlayerThread::operator()(), and BookBuilder< PLAYER >::Worker::operator()().

void HandicapPlayer::makeMiai ( HexPoint  p1,
HexPoint  p2 
) [private]

Takes two HexPoints and maps them to each other.

Definition at line 146 of file HandicapPlayer.cpp.

References m_responseMap.

Referenced by buildResponseMap(), and threeToOne().

std::string HandicapPlayer::Name (  )  const [inline, virtual]

returns "handicap".

Implements HexPlayer.

Definition at line 80 of file HandicapPlayer.hpp.

virtual HexPoint BenzenePlayer::Search ( const HexState state,
const Game game,
HexBoard brd,
const bitset_t consider,
double  maxTime,
double &  score 
) [protected, pure virtual, inherited]

Generates a move in the given gamestate.

Derived players must implement this method. Score can be stored in score.

Parameters:
state Position and color to play.
game Game history up to this point.
brd Board to use for work.
consider Moves to consider in this state.
maxTime Max time available for move.
score Score of the move to play.
Returns:
The move to play.

Implemented in MoHexPlayer, PerfectPlayer, and WolvePlayer.

Referenced by BenzenePlayer::GenMove().

HexPoint HandicapPlayer::Search ( HexBoard brd,
const Game game_state,
HexColor  color,
const bitset_t consider,
double  max_time,
double &  score 
) [protected, virtual]

Generates a move in the given gamestate using handicap strategy.

The handicap player must always be WHITE.

Handicap player wins playing second, so in this case any random move will suffice.

For future implementation: discard the naive responseMap and just do it here. Only build the responseMap for the places on the very edge of the board. Possibly edge and second row from edge... Depends on whether the theory player will handle all the edge cases.

Definition at line 28 of file HandicapPlayer.cpp.

References buildResponseMap(), FIRST_TO_PLAY, HexBoard::GetPosition(), HexBoard::Height(), HexAssert, Game::History(), INVALID_POINT, StoneBoard::IsPlayed(), LogInfo(), m_assume_added_stones, m_responseMap, m_width, BoardUtils::RandomEmptyCell(), RESIGN, UNUSED(), VERTICAL_COLOR, and HexBoard::Width().

bool BenzenePlayer::SearchSingleton (  )  const [inline, inherited]

Search states with only a single move?

Definition at line 76 of file BenzenePlayer.hpp.

References BenzenePlayer::m_search_singleton.

Referenced by MoHexEngine::MoHexParam(), and WolveEngine::WolveParam().

void BenzenePlayer::SetSearchSingleton ( bool  flag  )  [inline, inherited]
void HandicapPlayer::threeToOne ( const StoneBoard brd,
HexPoint  dest,
HexPoint  p1,
HexPoint  p2,
HexPoint  p3 
) [private]

Takes four HexPoints and maps p1, p2, and p3 to dest unless p1, p2, and/or p3 are already occupied, in which case there are a number of special cases.

  • If dest is occupied by black, p2 is viewed as dead and ignored. p1 is mirrored as most other cells are, and p3 is mirrored to the spot above or below it, just outside of the pattern of four.
  • If dest is occupied by white and any of the two other spaces are occupied, white plays the last spot.
  • If dest is occupied by white and if two or more of p1, p2, p3 remain unoccupied then p1 and p2 are mirrored and p3 is mapped to the spot above or below it, just outside of the pattern of four.
  • Finally, if white occupies any of p1, p2, or p3, then p1 and dest are mirrored as most of the other cells are, p2 is ignored (as it is either dead for black or occupied by white) and p3 is mapped to the spot above or below it, just outside of the pattern of four.

Definition at line 152 of file HandicapPlayer.cpp.

References StoneBoard::IsBlack(), StoneBoard::IsPlayed(), StoneBoard::IsWhite(), m_responseMap, makeMiai(), and MAX_WIDTH.

Referenced by buildResponseMap().


Member Data Documentation

Definition at line 45 of file HandicapPlayer.hpp.

Referenced by buildResponseMap(), and Search().

bool BenzenePlayer::m_fillinCausedWin [protected, inherited]

Definition at line 46 of file BenzenePlayer.hpp.

Referenced by BenzenePlayer::FillinCausedWin(), and BenzenePlayer::InitSearch().

HexColor BenzenePlayer::m_fillinWinner [protected, inherited]

Definition at line 48 of file BenzenePlayer.hpp.

Referenced by BenzenePlayer::InitSearch(), and PerfectPlayer::Search().

Definition at line 43 of file HandicapPlayer.hpp.

Definition at line 47 of file HandicapPlayer.hpp.

Referenced by buildResponseMap(), makeMiai(), Search(), and threeToOne().

int HandicapPlayer::m_width [private]

Definition at line 49 of file HandicapPlayer.hpp.

Referenced by buildResponseMap(), and Search().


The documentation for this class was generated from the following files:


6 Jan 2011 Doxygen 1.6.3