Пример #1
0
 /// <summary>
 /// Play the computer move found by the search.
 /// </summary>
 /// <param name="bFlash">       true to flash moving position</param>
 /// <param name="eMessageMode"> Which message to show</param>
 /// <param name="move">         Best move</param>
 /// <param name="iPermCount">   Permutation count</param>
 /// <param name="iDepth">       Depth of the search</param>
 /// <param name="iCacheHit">    Number of moves found in the translation table cache</param>
 /// <param name="stat">         Playing stat. Can be null</param>
 /// <returns>
 /// true if end of game, false if not
 /// </returns>
 private bool PlayComputerMove(bool bFlash, MessageModeE eMessageMode, ChessBoard.MovePosS move, int iPermCount, int iDepth, int iCacheHit, ComputerPlayingStat stat) {
     bool                        bRetVal;
     ChessBoard.MoveResultE      eResult;
     ChessBoard.PlayerColorE     eColorToPlay;
                                 
     eColorToPlay    = m_chessCtl.NextMoveColor;
     eResult         = m_chessCtl.DoMove(move,
                                         bFlash,
                                         iPermCount,
                                         iDepth,
                                         iCacheHit);
     if (stat != null) {
         stat.m_eResult = eResult;
     }
     bRetVal = DisplayMessage(eResult, eMessageMode);
     return(bRetVal);
 }
Пример #2
0
 /// <summary>
 /// Display a message related to the MoveStateE
 /// </summary>
 /// <param name="eMoveResult">  Move result</param>
 /// <param name="eMessageMode"> Message mode</param>
 /// <returns>
 /// true if it's the end of the game. false if not
 /// </returns>
 private bool DisplayMessage(ChessBoard.MoveResultE eMoveResult, MessageModeE eMessageMode) {
     bool    bRetVal;
     string  strOpponent;
     
     if (m_ePlayingMode == PlayingModeE.PlayerAgainstComputer) {
         if (m_chessCtl.ChessBoard.NextMoveColor == m_eComputerPlayingColor) {
             strOpponent = "Computer is ";
         } else {
             strOpponent = "You are ";
         }
     } else {
         strOpponent = (m_chessCtl.ChessBoard.NextMoveColor == ChessBoard.PlayerColorE.White) ? "White player is " : "Black player is ";
     }
     switch(eMoveResult) {
     case ChessBoard.MoveResultE.NoRepeat:
         bRetVal = false;
         break;
     case ChessBoard.MoveResultE.TieNoMove:
         if (eMessageMode != MessageModeE.Silent) {
             MessageBox.Show("Draw. " + strOpponent + "unable to move.");
         }
         bRetVal = true;
         break;
     case ChessBoard.MoveResultE.TieNoMatePossible:
         if (eMessageMode != MessageModeE.Silent) {
             MessageBox.Show("Draw. Not enough pieces to make a checkmate.");
         }
         bRetVal = true;
         break;
     case ChessBoard.MoveResultE.ThreeFoldRepeat:
         if (eMessageMode != MessageModeE.Silent) {
             MessageBox.Show("Draw. 3 times the same board.");
         }
         bRetVal = true;
         break;
     case ChessBoard.MoveResultE.FiftyRuleRepeat:
         if (eMessageMode != MessageModeE.Silent) {
             MessageBox.Show("Draw. 50 moves without moving a pawn or eating a piece.");
         }
         bRetVal = true;
         break;
     case ChessBoard.MoveResultE.Check:
         if (eMessageMode == MessageModeE.Verbose) {
             MessageBox.Show(strOpponent + "in check.");
         }
         bRetVal = false;
         break;
     case ChessBoard.MoveResultE.Mate:
         if (eMessageMode != MessageModeE.Silent) {
             MessageBox.Show(strOpponent + "checkmate.");
         }
         bRetVal = true;
         break;
     default:
         bRetVal = false;
         break;
     }
     return(bRetVal);
 }