Пример #1
0
        void AttachComputer()
        {
            computer              = new Computer();
            computer.OnMoveReady += delegate(Move bmove)
            {
                Piece pm = (Piece)Board._pieces[(bmove.From / 8) + "x" + (bmove.From % 8)];
                int   c = bmove.To / 8, r = bmove.To % 8;
                canvas1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                {
                    pm.Move(c, r);
                    statusTextBlock.Text = "Listo";

                    CheckAlert();
                }));
            };

            canvas1.OnMoveComplete += (int acol, int arow, int bcol, int brow, PieceColor color) =>
            {
                if (color == MainColor && Type != GameType.REPLAY)
                {
                    statusTextBlock.Text = "Pensando...";
                    computer.NextMove();
                }
            };
        }
Пример #2
0
 public void MoveFromHistory(ArrayList history, int n)
 {
     InitBoard();
     for (int i = 0; i < n; i++)
     {
         HMove move = (HMove)history[i];
         if (move.Nn == string.Empty)
         {
             move.Nn = Notations.fromAlgebraicNotation(move.An);
         }
         int c, r, c2, r2;
         Notations.parse(move.Nn, out c, out r, out c2, out r2);
         Piece p = (Piece)Board._pieces[c + "x" + r];
         p.Move(c2, r2);
         Board.whites = !Board.whites;
     }
 }