示例#1
0
        public Move Query(Board board, MoveOrganizer moveOrganizer)
        {
            int totalQuaryVal = 0;
              m_queryMoves.Clear();

              foreach (Move move in moveOrganizer)
              {
            if (move.Execute(board))
            {
              int currentQueryVal = 0;
              if (board.State.NonHitAndPawnMovesPlayed < 100 &&
            board.BoardHistoryFrequency() < 3 &&
            m_positionTable.TryGetValue(board.BoardHash(false), out currentQueryVal))
              {
            totalQuaryVal += currentQueryVal;
            m_queryMoves.Add(new QueryEntry(move, currentQueryVal));
              }
              move.UnExecute(board);
            }
              }

              //select a move using probabilety based on the quary value
              int selectValueCurrent = 0;
              int selectValueTarget = (int)Math.Round(m_moveSelector.NextDouble() * totalQuaryVal);
              for (int i = 0; i < m_queryMoves.Count; ++i)
              {
            selectValueCurrent += m_queryMoves[i].QueryScore;
            if (selectValueCurrent >= selectValueTarget)
            {
              OutputWriter.Write("Book moves: " + m_queryMoves.Count + ", Selecting: " + Math.Round((float)m_queryMoves[i].QueryScore / (float)totalQuaryVal, 6));
              return m_queryMoves[i].QueryMove;
            }
              }

              return null;
        }
示例#2
0
文件: Game.cs 项目: prezz/Firoz-Chess
 /// <summary>
 /// Used to obtain if the game is a draw due to the current board has been represented tree times in the game.
 /// </summary>
 /// <returns>True if the current board has been repeated three times. False otherwise.</returns>
 private bool IsDrawRepetitionOfMoves()
 {
     return(m_board.BoardHistoryFrequency() == 3);
 }