예제 #1
0
 //*********************************************************     
 //
 /// <summary>
 /// Default constructor
 /// </summary>
 //
 //*********************************************************     
 public frmPGNGamePicker() {
     InitializeComponent();
     m_pgnUtil               = new PgnUtil();
     m_strSelectedGame       = null;
     m_eStartingColor        = ChessBoard.PlayerColorE.White;
     m_chessBoardStarting    = null;
 }
 /// <summary>
 /// Class Ctor
 /// </summary>
 public frmPgnGamePicker()
 {
     InitializeComponent();
     m_pgnUtil               = new PgnUtil();
     SelectedGame            = null;
     StartingColor           = ChessBoard.PlayerColorE.White;
     StartingChessBoard      = null;
 }
예제 #3
0
        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="pgnUtil">          PGN utility class</param>
        /// <param name="streamInp">        Input stream containing the PGN file</param>
        /// <param name="iMinELO">          Minimum ELO in the PGN file</param>
        /// <param name="iMaxELO">          Maximum ELO in the PGN file</param>
        /// <param name="arrPlayers">       List of players found in the PGN file</param>
        /// <param name="strInpFileName">   Name of the input file.</param>
        /// <param name="iGameCount">       Number of games in the PGN file</param>
        public frmPgnFilter(PgnUtil pgnUtil, Stream streamInp, int iMinELO, int iMaxELO, string[] arrPlayers, string strInpFileName, int iGameCount)
            : this()
        {
            CheckBox    checkBox;

            m_pgnUtil   = pgnUtil;
            m_streamInp = streamInp;
            iMinELO     = iMinELO / 100 * 100;
            listBoxRange.Items.Clear();
            for (int iIndex = iMinELO; iIndex < iMaxELO; iIndex += 100) {
                checkBox            = new CheckBox();
                checkBox.Content    = new RangeItem(iIndex);
                checkBox.IsChecked  = true;
                listBoxRange.Items.Add(checkBox);
            }
            listBoxPlayer.Items.Clear();
            foreach (string strPlayer in arrPlayers) {
                checkBox            = new CheckBox();
                checkBox.Content    = strPlayer;
                checkBox.IsChecked  = true;
                listBoxPlayer.Items.Add(checkBox);
            }
            listBoxEnding.Items.Clear();
            checkBox            = new CheckBox();
            checkBox.Content    = "White Win";
            checkBox.IsChecked  = true;
            listBoxEnding.Items.Add(checkBox);
            checkBox            = new CheckBox();
            checkBox.Content    = "Black Win";
            checkBox.IsChecked  = true;
            listBoxEnding.Items.Add(checkBox);
            checkBox            = new CheckBox();
            checkBox.Content    = "Draws";
            checkBox.IsChecked  = true;
            listBoxEnding.Items.Add(checkBox);
            checkBoxAllRanges.IsChecked     = true;
            checkBoxAllPlayer.IsChecked     = true;
            checkBoxAllEndGame.IsChecked    = true;
            listBoxPlayer.IsEnabled         = false;
            listBoxRange.IsEnabled          = false;
            listBoxEnding.IsEnabled         = false;
            labelDesc.Content               = iGameCount.ToString() + " games found in the file '" + strInpFileName + "'";
        }
예제 #4
0
        /// <summary>
        /// 把一盘PGN对局里的前N个着法放入对局库中
        /// </summary>
        /// <param name="pgnFilename">PGN文件名</param>
        /// <returns>加入到开局库时,返回true
        /// 如果在解析PGN时遇到不规范的棋谱时,返回false,此时控制台会打印出错误信息</returns>
        public static bool AddPgnFileToOpeningBook(string bookFilename, string pgnFilename, int maxStep)
        {
            using (OpeningBook book = new OpeningBook(bookFilename))
            {
                // 从PGN文件里读出所有着法来,这里用的是纵列格式
                string[] allmoves = PgnUtil.GetAllMovesFromPgnFile(pgnFilename);

                Board board   = new Board();
                int   numMove = 0; // 记录已走了第几步了
                foreach (string strMove in allmoves)
                {
                    if (numMove >= maxStep)
                    {
                        break;
                    }
                    try
                    {
                        // 走一步后,把盘面生成zobrist值,保存到开局库里
                        // TODO: board.CreateMoveFromString(NotationConverter.Convert(board, strMove));
                        Move move = MoveNotation.CreateMoveFromChineseNotation(board, strMove);
                        board.MakeMove(move);
                        //   Console.WriteLine("==== " + strMove + "\n" + board);
                        ++numMove;
                        ulong zobrist = Zobrist.ZoristHash(board);
                        book.InsertBoardZobrist(zobrist);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("--- " + strMove + " ---");
                        Console.WriteLine(e.Message);
                        Console.WriteLine(board);
                        return(false);
                    }
                } // end 对每一着法循环结束
            }
            return(true);
        }
예제 #5
0
 //*********************************************************     
 //
 /// <summary>
 /// Class constructor
 /// </summary>
 /// <param name="pgnUtil">          PGN utility class</param>
 /// <param name="streamInp">        Input stream containing the PGN file</param>
 /// <param name="iMinELO">          Minimum ELO in the PGN file</param>
 /// <param name="iMaxELO">          Maximum ELO in the PGN file</param>
 /// <param name="arrPlayers">       List of players found in the PGN file</param>
 /// <param name="strInpFileName">   Name of the input file.</param>
 /// <param name="iGameCount">       Number of games in the PGN file</param>
 //
 //*********************************************************     
 public frmPGNFilter(PgnUtil pgnUtil, Stream streamInp, int iMinELO, int iMaxELO, string[] arrPlayers, string strInpFileName, int iGameCount) : this() {
     m_pgnUtil   = pgnUtil;
     m_streamInp = streamInp;
     iMinELO     = iMinELO / 100 * 100;
     checkedListBoxRange.Items.Clear();
     for (int iIndex = iMinELO; iIndex < iMaxELO; iIndex += 100) {
         checkedListBoxRange.Items.Add(new RangeItem(iIndex), true);
     }
     checkedListBoxPlayers.Items.Clear();
     foreach (string strPlayer in arrPlayers) {
         checkedListBoxPlayers.Items.Add(strPlayer, true);
     }
     checkedListBoxEnding.Items.Clear();
     checkedListBoxEnding.Items.Add("White win", true);
     checkedListBoxEnding.Items.Add("Black win", true);
     checkedListBoxEnding.Items.Add("Draws", true);
     checkBoxAllRanges.Checked     = true;
     checkBoxAllPlayer.Checked     = true;
     checkBoxAllEndGame.Checked    = true;
     checkedListBoxPlayers.Enabled = false;
     checkedListBoxRange.Enabled   = false;
     checkedListBoxEnding.Enabled  = false;
     labelDesc.Text                = iGameCount.ToString() + " games found in the file '" + strInpFileName + "'";
 }
예제 #6
0
 /// <summary>
 /// Filter the content of a PGN file
 /// </summary>
 private void FilterPGNFile() {
      PgnUtil    pgnUtil;
      
      pgnUtil = new PgnUtil();
      pgnUtil.CreatePGNSubset();
 }
예제 #7
0
 //*********************************************************     
 //
 /// <summary>
 /// Filter the content of a PGN file
 /// </summary>
 /// <param name="sender">   Sender object</param>
 /// <param name="e">        Event handler</param>
 //  
 //*********************************************************     
 private void filterAPGNFileToolStripMenuItem_Click(object sender, EventArgs e) {
      PgnUtil    pgnUtil;
      
      pgnUtil = new PgnUtil();
      pgnUtil.CreatePGNSubset();
 }