コード例 #1
0
        private Move GetCastleMove(string moveString)
        {
            string     castleRowForPlayer = State.IsPlayer1Turn ? "1" : "8";
            SimpleMove castleToKing;
            SimpleMove kingThroughCastle;

            if (IsQueenSideCastle(moveString))
            {
                castleToKing = new SimpleMove()
                {
                    Piece = getPiece("R"), StartingSquare = getSquare("a" + castleRowForPlayer), EndingSquare = getSquare("d" + castleRowForPlayer)
                };
                kingThroughCastle = new SimpleMove()
                {
                    Piece = getPiece("K"), StartingSquare = getSquare("e" + castleRowForPlayer), EndingSquare = getSquare("c" + castleRowForPlayer)
                };
            }
            else
            {
                castleToKing = new SimpleMove()
                {
                    Piece = getPiece("R"), StartingSquare = getSquare("h" + castleRowForPlayer), EndingSquare = getSquare("f" + castleRowForPlayer)
                };
                kingThroughCastle = new SimpleMove()
                {
                    Piece = getPiece("K"), StartingSquare = getSquare("e" + castleRowForPlayer), EndingSquare = getSquare("g" + castleRowForPlayer)
                };
            }
            return(new Move()
            {
                SimpleMoves = new List <SimpleMove> {
                    castleToKing, kingThroughCastle
                }
            });
        }
コード例 #2
0
 public void IssueGCodeCommands(SimpleMove move)
 {
     Sender.GoTo(move.StartingSquare.Center.X, move.StartingSquare.Center.Y, Settings.LiftHeight);
     System.Threading.Thread.Sleep(Settings.MoveWait);
     Sender.GoTo(move.StartingSquare.Center.X, move.StartingSquare.Center.Y, Settings.PieceHeight);
     System.Threading.Thread.Sleep(Settings.DropWait);
     Sender.Pick();
     System.Threading.Thread.Sleep(Settings.MoveWait);
     Sender.GoTo(move.StartingSquare.Center.X, move.StartingSquare.Center.Y, Settings.LiftHeight);
     System.Threading.Thread.Sleep(Settings.MoveWait);
     Sender.GoTo(move.EndingSquare.Center.X, move.EndingSquare.Center.Y, Settings.LiftHeight);
     System.Threading.Thread.Sleep(Settings.MoveWait);
     Sender.GoTo(move.EndingSquare.Center.X, move.EndingSquare.Center.Y, Settings.PieceHeight);
     System.Threading.Thread.Sleep(Settings.MoveWait);
     Sender.Play();
     System.Threading.Thread.Sleep(Settings.DropWait);
     Sender.GoTo(move.EndingSquare.Center.X, move.EndingSquare.Center.Y, Settings.LiftHeight);
     System.Threading.Thread.Sleep(Settings.MoveWait);
 }
コード例 #3
0
        public Move GetMove(string moveString)
        {
            Move move = new Move();

            ////Nc1-Nd3
            if (isCapture(moveString))
            {
                List <string> captureMoveString            = moveString.Split(new Char[] { 'x' }).ToList();
                Piece         capturingPiece               = getPiece(captureMoveString[0]);
                Square        capturingPieceStartingSquare = getSquare(captureMoveString[0]);
                Piece         capturedPiece       = getPiece(captureMoveString[1]);
                Square        capturedOnSquare    = getSquare(captureMoveString[1]);
                SimpleMove    removeCapturedPiece = new SimpleMove()
                {
                    Piece = capturedPiece, StartingSquare = capturedOnSquare, EndingSquare = State.getDiscardSquare(Squares)
                };
                SimpleMove moveToCapturedSquare = new SimpleMove()
                {
                    Piece = capturingPiece, StartingSquare = capturingPieceStartingSquare, EndingSquare = capturedOnSquare
                };
                move.addMove(removeCapturedPiece);
                State.NotifyPieceWasTaken();
                move.addMove(moveToCapturedSquare);
            }
            else if (isCastle(moveString))
            {
                move = GetCastleMove(moveString);
            }
            else
            {
                Piece         piece   = getPiece(moveString);
                List <Square> squares = getSquares(moveString);
                move.addMove(piece, squares[0], squares[1]);
            }

            return(move);
        }
コード例 #4
0
 public void addMove(SimpleMove simpleMove)
 {
     SimpleMoves.Add(simpleMove);
 }