コード例 #1
0
        /// <summary>
        /// コメントからPVを探します。
        /// </summary>
        public void SetupPVInfo(Board board)
        {
            Move move = null;

            if (VariationNode != null)
            {
                VariationNode.SetupPVInfo(board);
            }

            // このノードの手を指して、変化の基準局面を進めます。
            if (LiteralMove != null && LiteralMove.Validate())
            {
                move = MakeMove(board, new List <Exception>());
                if (move == null || !move.Validate())
                {
                    Log.Error("'{0}'が正しく着手できません。", move);
                    return;
                }
            }

            for (var i = 0; i < CommentList.Count();)
            {
                var pvInfo = ParsePVInfo(CommentList[i], board);
                if (pvInfo != null)
                {
                    PVInfoList.Add(pvInfo);
                    CommentList.RemoveAt(i);
                }
                else
                {
                    ++i;
                }
            }

            if (NextNode != null)
            {
                NextNode.SetupPVInfo(board);
            }

            if (move != null)
            {
                board.Undo();
            }
        }
コード例 #2
0
        /// <summary>
        /// ノード全体を文字列化します。
        /// </summary>
        private void MakeString(StringBuilder sb, int nmoves)
        {
            if (LiteralMove != null)
            {
                var str    = LiteralMove.ToString();
                var hanlen = str.HankakuLength();

                sb.AppendFormat(" - {0}{1}",
                                str, new string(' ', 8 - hanlen));
            }

            if (NextNode != null)
            {
                NextNode.MakeString(sb, nmoves + 1);
            }

            if (VariationNode != null)
            {
                sb.AppendLine();
                sb.Append(new string(' ', 11 * nmoves));

                VariationNode.MakeString(sb, nmoves);
            }
        }