Beispiel #1
0
 //*********************************************************     
 //
 /// <summary>
 /// Class constructor
 /// </summary>
 //  
 //*********************************************************     
 internal frmSearchMode(SearchEngine.SearchMode searchMode, BoardEvaluationUtil boardEvalUtil) : this() {
     int     iPos;
     
     m_searchMode    = searchMode;
     m_boardEvalUtil = boardEvalUtil;
     foreach (IBoardEvaluation boardEval in m_boardEvalUtil.BoardEvaluators) {
         iPos = comboBoxWhiteBEval.Items.Add(boardEval.Name);
         if (searchMode.m_boardEvaluationWhite == boardEval) {
             comboBoxWhiteBEval.SelectedIndex = iPos;
         }
         iPos = comboBoxBlackBEval.Items.Add(boardEval.Name);
         if (searchMode.m_boardEvaluationBlack == boardEval) {
             comboBoxBlackBEval.SelectedIndex = iPos;
         }
     }
     checkBoxTransTable.Checked = ((searchMode.m_eOption & SearchEngine.SearchMode.OptionE.UseTransTable) != 0);
     if (searchMode.m_eThreadingMode == SearchEngine.SearchMode.ThreadingModeE.OnePerProcessorForSearch) {
         radioButtonOnePerProc.Checked   = true;
     } else if (searchMode.m_eThreadingMode == SearchEngine.SearchMode.ThreadingModeE.DifferentThreadForSearch) {
         radioButtonOneForUI.Checked     = true;
     } else {
         radioButtonNoThread.Checked     = true;
     }
     checkBoxBookOpening.Checked     = ((searchMode.m_eOption & SearchEngine.SearchMode.OptionE.UseBook) != 0);
     if ((searchMode.m_eOption & SearchEngine.SearchMode.OptionE.UseAlphaBeta) != 0) {
         radioButtonAlphaBeta.Checked    = true;
     } else {
         radioButtonMinMax.Checked       = true;
         checkBoxTransTable.Enabled      = false;
     }
     if (searchMode.m_iSearchDepth == 0) {
         radioButtonAvgTime.Checked = true;
         textBoxTimeInSec.Text      = searchMode.m_iTimeOutInSec.ToString();
         plyCount.Value             = 6;
     } else {
         if ((searchMode.m_eOption & SearchEngine.SearchMode.OptionE.UseIterativeDepthSearch) == SearchEngine.SearchMode.OptionE.UseIterativeDepthSearch) {
             radioButtonFixDepthIterative.Checked = true;
         } else {
             radioButtonFixDepth.Checked = true;
         }
         plyCount.Value              = searchMode.m_iSearchDepth;
         textBoxTimeInSec.Text       = "15";
     }
     switch(searchMode.m_eRandomMode) {
     case SearchEngine.SearchMode.RandomModeE.Off:
         radioButtonRndOff.Checked   = true;
         break;
     case SearchEngine.SearchMode.RandomModeE.OnRepetitive:
         radioButtonRndOnRep.Checked = true;
         break;
     default:
         radioButtonRndOn.Checked    = true;
         break;
     }
     textBoxTransSize.Text = (TransTable.TranslationTableSize / 1000000 * 32).ToString();    // Roughly 32 bytes / entry
 }
 //*********************************************************     
 //
 /// <summary>
 /// Form constructor
 /// </summary>
 /// <param name="boardEvalUtil">        Board evaluation utility class</param>
 /// <param name="searchModeTemplate">   Search mode template</param>
 //  
 //*********************************************************     
 public frmTestBoardEval(BoardEvaluationUtil boardEvalUtil, SearchEngine.SearchMode searchModeTemplate) : this() {
     m_searchMode        = new SearchEngine.SearchMode(boardEvalUtil.BoardEvaluators[0],
                                                       boardEvalUtil.BoardEvaluators[0],
                                                       SearchEngine.SearchMode.OptionE.UseAlphaBeta,
                                                       searchModeTemplate.m_eThreadingMode,
                                                       4,
                                                       0,
                                                       searchModeTemplate.m_eRandomMode);
     foreach (IBoardEvaluation boardEval in boardEvalUtil.BoardEvaluators) {
         comboBoxWhiteBEval.Items.Add(boardEval.Name);
         comboBoxBlackBEval.Items.Add(boardEval.Name);
     }
     comboBoxWhiteBEval.SelectedIndex = 0;
     comboBoxBlackBEval.SelectedIndex = (comboBoxBlackBEval.Items.Count == 0) ? 0 : 1;
     m_boardEvalUtil     = boardEvalUtil;
     SetButtonState();
 }
Beispiel #3
0
 //*********************************************************     
 //
 /// <summary>
 /// Form constructor
 /// </summary>
 //  
 //*********************************************************     
 public frmChessBoard() {
     SrcChess.Properties.Settings            settings;
     SearchEngine.SearchMode.OptionE         eOption;
     SearchEngine.SearchMode.ThreadingModeE  eThreadingMode;
     int                                     iTransTableSize;
     IBoardEvaluation                        boardEvalWhite;
     IBoardEvaluation                        boardEvalBlack;
     ChessControl.ChessControlColorInfo      colorInfo;
     
     InitializeComponent();
     settings                        = SrcChess.Properties.Settings.Default;
     colorInfo.m_colBlackPiece       = NameToColor(settings.BlackPieceColor);
     colorInfo.m_colWhitePiece       = NameToColor(settings.WhitePieceColor);
     colorInfo.m_colLiteCase         = NameToColor(settings.LiteCaseColor);
     colorInfo.m_colDarkCase         = NameToColor(settings.DarkCaseColor);
     iTransTableSize                 = (settings.TransTableSize < 5 || settings.TransTableSize > 256) ? 32 : settings.TransTableSize;
     TransTable.TranslationTableSize = iTransTableSize / 32 * 1000000;
     eOption                         = settings.UseAlphaBeta ? SearchEngine.SearchMode.OptionE.UseAlphaBeta : SearchEngine.SearchMode.OptionE.UseMinMax;
     if (settings.UseBook) {
         eOption |= SearchEngine.SearchMode.OptionE.UseBook;
     }
     
     if (settings.UseTransTable) {
         eOption |= SearchEngine.SearchMode.OptionE.UseTransTable;
     }
     if (settings.UsePlyCountIterative) {
         eOption |= SearchEngine.SearchMode.OptionE.UseIterativeDepthSearch;
     }
     switch(settings.UseThread) {
     case 0:
         eThreadingMode = SearchEngine.SearchMode.ThreadingModeE.Off;
         break;
     case 1:
         eThreadingMode = SearchEngine.SearchMode.ThreadingModeE.DifferentThreadForSearch;
         break;
     default:
         eThreadingMode = SearchEngine.SearchMode.ThreadingModeE.OnePerProcessorForSearch;
         break;
     }
     m_boardEvalUtil                     = new BoardEvaluationUtil();
     boardEvalWhite                      = m_boardEvalUtil.FindBoardEvaluator(settings.WhiteBoardEval);
     if (boardEvalWhite == null) {
         boardEvalWhite = m_boardEvalUtil.BoardEvaluators[0];
     }
     boardEvalBlack                      = m_boardEvalUtil.FindBoardEvaluator(settings.BlackBoardEval);
     if (boardEvalBlack == null) {
         boardEvalBlack = m_boardEvalUtil.BoardEvaluators[0];
     }
     m_searchMode                        = new SearchEngine.SearchMode(boardEvalWhite,
                                                                       boardEvalBlack,
                                                                       eOption,
                                                                       eThreadingMode,
                                                                       settings.UsePlyCount | settings.UsePlyCountIterative ? ((settings.PlyCount > 1 && settings.PlyCount < 9) ? settings.PlyCount : 6) : 0,  // Maximum depth
                                                                       settings.UsePlyCount | settings.UsePlyCountIterative ? 0 : (settings.AverageTime > 0 && settings.AverageTime < 1000) ? settings.AverageTime : 15,
                                                                       (settings.RandomMode >= 0 && settings.RandomMode <= 2) ? (SearchEngine.SearchMode.RandomModeE)settings.RandomMode : SearchEngine.SearchMode.RandomModeE.On); // Average time
     m_chessCtl                          = new LocalChessControl();
     m_chessCtl.Location                 = new Point(0, 0);
     m_chessCtl.Size                     = new Size(60 * 9, 60 * 9);
     m_chessCtl.UpdateCmdState          += new EventHandler(m_chessCtl_UpdateCmdState);
     m_chessCtl.Father                   = this;
     m_chessCtl.ColorInfo                = colorInfo;
     panelBoard.Controls.Add(m_chessCtl);
     PlayingMode                         = PlayingModeE.PlayerAgainstComputer;
     m_eComputerPlayingColor             = ChessBoard.PlayerColorE.Black;
     m_lostPieceBlack                    = new LostPiecesControl();
     m_lostPieceBlack.Location           = new Point(0,0);
     m_lostPieceBlack.Size               = new Size(200, 200);
     m_lostPieceBlack.Dock               = DockStyle.Fill;
     m_lostPieceBlack.ChessControl       = m_chessCtl;
     m_lostPieceBlack.Color              = true;
     panelBlackLostPiece.Controls.Add(m_lostPieceBlack);
     m_lostPieceWhite                    = new LostPiecesControl();
     m_lostPieceWhite.Location           = new Point(0,0);
     m_lostPieceWhite.Size               = new Size(200, 200);
     m_lostPieceWhite.Dock               = DockStyle.Fill;
     m_lostPieceWhite.ChessControl       = m_chessCtl;
     m_lostPieceWhite.Color              = false;
     panelWhiteLostPiece.Controls.Add(m_lostPieceWhite);
     m_moveViewer                        = new MoveViewer();
     m_moveViewer.Location               = new Point(0,0);
     m_moveViewer.Size                   = panelMoveList.Size;
     m_moveViewer.Dock                   = DockStyle.Fill;
     m_moveViewer.NewMoveSelected       += new MoveViewer.NewMoveSelectedHandler(m_moveViewer_NewMoveSelected);
     m_moveViewer.DisplayMode            = (settings.MoveNotation == 0) ? MoveViewer.DisplayModeE.MovePos : MoveViewer.DisplayModeE.PGN;
     panelMoveList.Controls.Add(m_moveViewer);
     m_chessCtl.MoveListUI               = this;
     m_chessCtl.MoveSelected            += new ChessControl.MoveSelectedEventHandler(m_chessCtl_MoveSelected);
     m_chessCtl.QueryPiece              += new ChessControl.QueryPieceEventHandler(m_chessCtl_QueryPiece);
     m_chessCtl.QueryPawnPromotionType  += new ChessControl.QueryPawnPromotionTypeEventHandler(m_chessCtl_QueryPawnPromotionType);
     m_bSecondThreadBusy                 = false;
     timer1.Tick                        += new EventHandler(timer1_Tick);
     timer1.Start();
     ResizeChessCtl();
     SetCmdState();
     ShowSearchMode();
     flashPieceToolStripMenuItem.Checked  = settings.FlashPiece;
     pgnNotationToolStripMenuItem.Checked = (m_moveViewer.DisplayMode == MoveViewer.DisplayModeE.PGN);
 }