Ejemplo n.º 1
0
        public void createNewVia(Point tP)
        {
            Variation v = new Variation();

            v.record = origin.record;
            addVariation(v);
            v.addToVariation(tP);
        }
Ejemplo n.º 2
0
        }//返回是否执行成功

        public bool Next()//返回是否成功
        {
            int  index;
            Move m;

            if (mainvariation.movelist.Count == 0)
            {
                return(false);
            }
            if (presentMove == null && mainvariation.movelist.Count != 0)
            {
                m = mainvariation.movelist[0];
            }
            else
            {
                index = presentMove.origin.movelist.IndexOf(presentMove);
                if (presentMove.origin.movelist.IndexOf(presentMove) == presentMove.origin.movelist.Count - 1)
                {
                    return(false);
                }
                m = presentMove.origin.movelist[index + 1];
            }
            if (m.hasvia)
            {
                chooseVarDlg dlg = new chooseVarDlg();
                string       s   = m.movetostring();
                if (m.turnCount % 2 == 1)
                {
                    s = Convert.ToString((m.turnCount + 1) / 2) + "..." + s;
                }
                dlg.listBox1.Items.Add(s);
                foreach (Variation v in m.varList)
                {
                    dlg.listBox1.Items.Add(v.varToString());
                }
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    if (dlg.listBox1.SelectedIndex == 0)
                    {
                        presentMove = m;
                    }
                    else
                    {
                        Variation v0 = m.varList[dlg.listBox1.SelectedIndex - 1];
                        presentMove = v0.movelist[0];
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                presentMove = m;
            }
            return(true);
        }
Ejemplo n.º 3
0
 public void addVariation(Variation v)
 {
     if (!hasvia)
     {
         hasvia  = true;
         varList = new List <Variation>();
     }
     v.startstep = this;
     varList.Add(v);
 }
Ejemplo n.º 4
0
        }//返回是否成功

        public void ToBoard(BoardOfFIR board, Move move)
        {
            board.clearBoard();
            Variation v = this.TopresentVar(move);

            foreach (Move m in v.movelist)
            {
                board.setPieceType(m.getP(), (PieceType)(m.turnCount % 2));
                board.stepRecord[m.getP().X, m.getP().Y] = m.turnCount + 1;
            }
            board.setTurn(move.turnCount + 1);
        }
Ejemplo n.º 5
0
        void checkSymmetry()//仅在第5回合
        {
            int       x1, x2, y1, y2;
            Variation v = record.TopresentVar();

            x1 = v.movelist[0].getP().X; x2 = v.movelist[2].getP().X; y1 = v.movelist[0].getP().Y; y2 = v.movelist[2].getP().Y;
            symmetryLine[0] = (y1 == y2 && x1 + x2 == 14) || (x1 == 7 && x2 == 7);
            symmetryLine[1] = (x1 == x2 && y1 + y2 == 14) || (y1 == 7 && y2 == 7);
            symmetryLine[2] = (x1 == y2 && y1 == x2) || (x1 == y1 && x2 == y2);
            symmetryLine[3] = (x2 + y2 == 14 && x1 + y1 == 14) || (x1 + y2 == 14 && x2 + y1 == 14);
            x1 = v.movelist[1].getP().X; x2 = v.movelist[3].getP().X; y1 = v.movelist[1].getP().Y; y2 = v.movelist[3].getP().Y;
            symmetryLine[0] = symmetryLine[0] && ((y1 == y2 && x1 + x2 == 14) || (x1 == 7 && x2 == 7));
            symmetryLine[1] = symmetryLine[1] && ((x1 == x2 && y1 + y2 == 14) || (y1 == 7 && y2 == 7));
            symmetryLine[2] = symmetryLine[2] && ((x1 == y2 && y1 == x2) || (x1 == y1 && x2 == y2));
            symmetryLine[3] = symmetryLine[3] && ((x2 + y2 == 14 && x1 + y1 == 14) || (x1 + y2 == 14 && x2 + y1 == 14));
        }
Ejemplo n.º 6
0
        public Variation TopresentVar(Move m)
        {
            Variation v = new Variation();

            while (true)
            {
                v.movelist.Insert(0, m);
                if (m.turnCount == 0)
                {
                    break;
                }
                if (m.turnCount == m.origin.startstep.turnCount)
                {
                    m = m.origin.startstep;
                }
                m = m.origin.movelist[m.origin.movelist.IndexOf(m) - 1];
            }
            return(v);
        }
Ejemplo n.º 7
0
 public bool Undo()
 {
     if (presentMove == null)
     {
         return(false);
     }
     if (presentMove.turnCount == 0)
     {
         presentMove = null;
         return(true);
     }
     if (presentMove.turnCount == presentMove.origin.startstep.turnCount)
     {
         Variation v = presentMove.origin.startstep.origin;
         int       x = v.movelist.IndexOf(presentMove.origin.startstep);
         presentMove = v.movelist[x - 1];
     }
     else
     {
         presentMove = presentMove.origin.movelist[presentMove.origin.movelist.IndexOf(presentMove) - 1];
     }
     return(true);
 }//返回是否执行成功