private void engine_OnMove(Square source, Square target, Type pawnPromotedTo) { if (stopwatch.Elapsed.TotalSeconds < 1) System.Threading.Thread.Sleep((int)(1000 - stopwatch.ElapsedMilliseconds)); this.Board.Move(source, target, pawnPromotedTo); }
public PieceMove(Piece piece, Square target, Piece capturedPiece = null) { this.Piece = piece; this.Source = piece.Square; this.Target = target; this.CanCapture = true; this.CapturedPiece = capturedPiece ?? this.Board[target]; }
internal static Image GetSquareImage(Square square, Piece piece = null) { if (piece == null) return boardImageCache["Empty"][square.GetSquareColor()]; var squareColor = square.GetSquareColor(); var key = piece.Player + piece.GetType().Name; return boardImageCache[key][squareColor]; }
private Board() { matrix = new Square[NUM_ROWS, NUM_ROWS]; whitePieces = new List(); blackPieces = new List(); this.Size = new Size(480, 480); this.Location = new Point(30, 30); // Create the squares int h; int v = 0; for (int i = 0; i < NUM_ROWS; i++) { h = 0; for (int j = 0; j < NUM_ROWS; j++) { matrix[i, j] = new Square(new Position(i, j)); if ((i + j) % 2 == 0) { matrix[i, j].BackgroundImage = Image.FromFile(path + "//WhiteWood.gif"); } else { matrix[i, j].BackgroundImage = Image.FromFile(path + "//BlackWood.gif"); } matrix[i, j].Name = "square" + i + "" + j; //square00, square01, etc. matrix[i, j].Location = new Point(h, v); matrix[i, j].Click += new System.EventHandler(this.square_Click); h += 60; matrix[i, j].Size = new Size(60, 60); this.Controls.Add(matrix[i, j]); } v += 60; } }
public abstract bool Attacks(Square piece, Board board);
public FigureOnSquare(Figure figure, Square square) { Figure = figure; Square = square; }
/** * Two Part MoveHandler * First Square received is pushed onto a stack. * Second Square is then received, and the First Square gets popped. They are combined to create a move. * If the Move is valid it is played. If it is not, the Second Square gets pushed onto the stack, and the cycle repeats. */ public void MoveHandler(Square tapped) { if (tutorialFlag) { // Play differently if in tutorial mode Console.WriteLine("Tutorial square " + tapped.Name + " tapped"); tutorialQueue.Enqueue(tapped); } else if (blackIsAI && whiteIsAI) { // Ignore non-AI input Console.WriteLine("Both players AI, square tap ignored."); } else if ((blackIsAI && !position.whiteMove) || (whiteIsAI & position.whiteMove)) { // Ignore input during AI turn Console.WriteLine("Safety ignore."); } else { Console.WriteLine("Square " + tapped.Name + " tapped"); moveQueue.Enqueue(tapped); if (this.oneClick) { Square orig = moveQueue.Dequeue(); Square dest = moveQueue.Dequeue(); if (orig.getSquareNumber() == dest.getSquareNumber()) { DoColourations(); this.oneClick = false; return; } PieceType promoteTo = ((dest.getSquareNumber() <= 7 | dest.getSquareNumber() > 55) & (orig.getPiece().Equals(PieceType.p) | orig.getPiece().Equals(PieceType.P))) ? getPromotion(orig.getPiece()) : PieceType.Empty; Move current = new Move(orig.getSquareNumber(), dest.getSquareNumber(), promoteTo); if (MoveCheck(current)) { performMove(current); } else { moveQueue.Enqueue(dest); DoColourations(); this.ColourLegalMoves(dest.getSquareNumber()); } } else { this.ColourLegalMoves(tapped.getSquareNumber()); this.oneClick = true; } } }
//Used to get the sqaure name from another thread public static String CopySquare(Square square) { String result; GetNameDelegate a; a = new GetNameDelegate(GetName); result = square.Dispatcher.Invoke(a, square) as String; return result; }
protected IEnumerable<Square> MoveUntilObstruction(Square from, MoveDirection dir) { var target = from.Move(dir); bool last = false; var player = this.Board[from].Player; while (target.HasValue && (this.Board[target.Value] == null || this.Board[target.Value].Player != player) && !last) { yield return target.Value; last = this.Board[target.Value] != null; target = target.Move(dir); } }
public Piece this[Square square] { get { return pieces[(int)square]; } private set { pieces[(int)square] = value; if (value == null) { this.OnSquareChanged(square); return; } var source = value.Square; if (source != square) { pieces[(int)value.Square] = null; value.Square = square; } } }
private bool MatchMove(Square source, Square target, int rowDelta, int columnDelta) { return(((source.Row + rowDelta) == target.Row) && ((source.Column + columnDelta) == target.Column)); }
public override void Move(Square source, Square dest, bool silentMode = false) { int source_col = Convert.ToInt16(Convert.ToChar(source.Name.Substring(0, 1))); int source_row = Convert.ToInt16(source.Name.Substring(1, 1)); int dest_col = Convert.ToInt16(Convert.ToChar(dest.Name.Substring(0, 1))); int dest_row = Convert.ToInt16(dest.Name.Substring(1, 1)); if (IsMoveValid(dest)) { // Gewoehnlicher Zug ohne Angriff if (source_col == dest_col) { if (!IsMoveBlocked(dest)) { string last_pos = this.Current_position; this.Current_position = GetSquarenameFromCoordinates(dest_col, dest_row); if (!this.game.board.IsKingInCheck(this.Color)) { if (!silentMode) { source.Content = ""; this.game.board.lastAction = "BEWEGE " + this.Desc + " VON " + source.Name + " AUF " + dest.Name; isMoved = true; // Neuer Logeintrag wird initialisiert LogEntry log = new LogEntry(this, last_pos, this.Current_position); // Zieht ein Bauer im Doppelschritt, // kann dieser unmittelbar danach 'en passant' geschlagen werden if (Math.Abs(source_row - dest_row) == 2) { this.game.GetActivePlayer().DoubleStepMovedPawn = this; } // Zieht ein Bauer auf die letzte Linie, kann er umgewandelt werden if (dest_row == 8) { // Ein modales Fenster zur Auswahl der neuen Figur wird geöffnet PromotePawn(); // Der Logeintrag wird um die umgewandelte Figur ergänzt log.PromotedIn = this.promotedIn; } log.PlacedInCheck = this.game.board.IsKingInCheck(this.game.GetWaitingPlayer().Color); this.game.logger.Add(log); this.game.View.movesList.Items.Add(log); } } // Zug Rückgängig machen, wenn sich nach dem Zug // der König im Schach befinden würde else { this.Current_position = last_pos; throw new PlacedInCheckException(); } } else { throw new BlockedMoveException(); } } // Angriffszug else { Chessman opponent = this.game.board.GetChessmanAtSquare(dest); string last_pos = this.Current_position; // Standardangriff if (opponent != null) { this.Current_position = GetSquarenameFromCoordinates(dest_col, dest_row); this.game.board.chessman.Remove(opponent); if (!this.game.board.IsKingInCheck(this.Color)) { if (!silentMode) { source.Content = ""; isMoved = true; this.game.board.lastAction = this.Desc + " SCHLÄGT " + opponent.Desc + " AUF " + dest.Name; // Neuer Logeintrag wird initialisiert LogEntry log = new LogEntry(this, last_pos, this.Current_position); log.OpponentMan = opponent; // Zieht ein Bauer auf die letzte Linie, kann er umgewandelt werden if (dest_row == 8) { PromotePawn(); log.PromotedIn = this.promotedIn; } log.PlacedInCheck = this.game.board.IsKingInCheck(this.game.GetWaitingPlayer().Color); this.game.logger.Add(log); this.game.View.movesList.Items.Add(log); } } // Zug Rückgängig machen, wenn sich nach dem Zug // der König im Schach befinden würde else { this.Current_position = last_pos; this.game.board.chessman.Add(opponent); throw new PlacedInCheckException(); } } // En Passant Angriff else { string opponent_curr_pos = GetSquarenameFromCoordinates(dest_col, 5); Square opponent_pos_square = this.game.board.GetSquare(opponent_curr_pos); opponent = this.game.board.GetChessmanAtSquare(opponent_pos_square); this.Current_position = GetSquarenameFromCoordinates(dest_col, dest_row); this.game.board.chessman.Remove(opponent); if (!this.game.board.IsKingInCheck(this.Color)) { if (!silentMode) { source.Content = ""; opponent_pos_square.Content = ""; isMoved = true; this.game.board.lastAction = this.Desc + " SCHLÄGT " + opponent.Desc + " AUF " + dest.Name + " IM VORBEIGEHEN (EN PASSANT)"; // Neuer Logeintrag LogEntry log = new LogEntry(this, last_pos, this.Current_position); log.OpponentMan = opponent; log.TookEnPassant = true; log.PlacedInCheck = this.game.board.IsKingInCheck(this.game.GetWaitingPlayer().Color); this.game.logger.Add(log); this.game.View.movesList.Items.Add(log); } } // Zug Rückgängig machen, wenn sich nach dem Zug // der König im Schach befinden würde else { this.Current_position = last_pos; this.game.board.chessman.Add(opponent); throw new PlacedInCheckException(); } } } } else { throw new InvalidMoveException(); } }
public static Move MakeMove(Square org, Square dst, PieceType pt) { return((Move)((ushort)MoveType.PROMOTE + ((((pt - PieceType.NIHT) << 6) + org) << 6) + dst)); }
public static Move MakeMove(Square org, Square dst, MoveType MT) { return((Move)((ushort)MT + (org << 6) + dst)); }
public abstract override bool IsMoveBlocked(Square dest);
/** * Draws the Board. 600x600 Pixels. * Adds EventHandlers to the Squares */ internal void drawBoard() { this.Width = 600; this.Height = 600; squares = new Square[64]; for (int i = 0; i < 8; i++) { squares[i] = new Square(getSquareName(i, 0), this.getSquareNumber(i, 0)); if (gamecon.debugging) { squares[i].AddHandler(ButtonBase.MouseLeftButtonDownEvent, new RoutedEventHandler(TappedSquare), true); } squares[i].AddHandler(ButtonBase.TouchDownEvent, new RoutedEventHandler(TappedSquare), true); this.Children.Add(squares[i]); Canvas.SetTop(squares[i], 0); Canvas.SetLeft(squares[i], i * 75); for (int j = 1; j < 8; j++) { squares[i + j * 8] = new Square(getSquareName(i, j), this.getSquareNumber(i, j)); if (gamecon.debugging) { squares[i + j * 8].AddHandler(ButtonBase.MouseLeftButtonDownEvent, new RoutedEventHandler(TappedSquare), true); } squares[i + j * 8].AddHandler(ButtonBase.TouchDownEvent , new RoutedEventHandler(TappedSquare), true); this.Children.Add(squares[i + j * 8]); Canvas.SetTop(squares[i + j * 8], j * 75); Canvas.SetLeft(squares[i + j * 8], i * 75); } } // Add TagVisalizers to the Squares, routing to the RecognizedSquare method foreach (Square s in squares) { s.MyTagVisualizer.AddHandler(TagVisualizer.VisualizationAddedEvent, new RoutedEventHandler(RecognizedSquare), true); s.MyTagVisualizer.AddHandler(TagVisualizer.VisualizationRemovedEvent, new RoutedEventHandler(RecognizedSquare), true); } this.ColourBoard(); }
public Piece this[Square? square] { get { return square.HasValue ? pieces[(int)square.Value] : null; } }
public PieceMove GetValidMove(Square target) { return this.GetValidMoves().FirstOrDefault(i => i.Target == target); }
public void Draw(Image image, Square square, bool monochrome = false) { using (var g = Graphics.FromImage(image)) Draw(g, square, monochrome); }
//public static bool operator == (Move move1, Move move2) //{ // // If both are null, or both are same instance, return true. // if (ReferenceEquals (move1, move2)) // { // return true; // } // // If one is null, but not both, return false. // if (ReferenceEquals (null, move1) // || ReferenceEquals (null, move2)) // { // return false; // } // // Return true if the fields match: // return move1._Value == move2._Value; //} //public static bool operator != (Move move1, Move move2) //{ // return !(move1 == move2); //} #endregion public static Move MakeMove(Square org, Square dst) { return((Move)((ushort)MoveType.NORMAL + (org << 6) + dst)); }
public void Draw(Graphics graphics, Square square, bool monochrome = false) { var rect = square.GetRectangle(); if (monochrome) graphics.DrawImageUnscaled(Grayscale(Images.GetSquareImage(square, this[square])), rect); else graphics.DrawImageUnscaled(Images.GetSquareImage(square, this[square]), rect); }
/** * Promotes a piece by redrawing it. */ private void promotePiece(Square sq, PieceType p) { sq.Children.Clear(); board.drawPiece(p, sq); }
public IList<Piece> GetAttackers(Square square, PlayerColor attacker) { var ret = new List<Piece>(); //Find adjacent king if (this[attacker].First(i => i is King).Square.IsAdjacent(square)) ret.Add(this[attacker].First(i => i is King)); //Find attacking Pawn foreach (var dir in Pawn.GetAttackingDirection(attacker).GetDiagonals()) { var pawn = this[square.Move(dir)] as Pawn; if (pawn != null && pawn.Player == attacker) ret.Add(pawn); } var opponents = this[attacker].Where(i => !(i is King)); var moves = opponents.Where(i => !(i is King || i is Pawn)).SelectMany(o => o.GetValidMoves().Where(i => i.Target == square && i.CanCapture)); ret.AddRange(moves.Select(i => i.Piece)); return ret; }
private static void ResetRowAndColumn(out int r, out int c, out Square s, int R, int C, Square S) { r = R; c = C; s = S; }
public bool IsUnderAttack(Square square, PlayerColor attacker) { return GetAttackers(square, attacker).Any(); }
public override bool Attacks(Square square, Board board) { return(Rook.Attacks(this, square, board) || Bishop.Attacks(this, square, board)); }
public bool Move(Square source, Square target, Type promotePawnTo) { var piece = this[source]; if (this.Turn != piece.Player || !this.IsActive) return false; var move = piece.GetValidMove(target); if (move == null) return false; if (!IsValid(move)) return false; MoveCore(move, true); this.CurrentPlayer.OnMove(move); //The move is valid ready to proceed CastleAvailabityChangeTest(move.Piece); this.History.Add(move); this.Turn = this.Turn.Opponent(); if (move is KingCastleMove) Castle(move as KingCastleMove); if (move.HasPromotion) { move.PawnPromotedTo = promotePawnTo; Promote(piece, promotePawnTo); } if (this.PieceMoved != null) this.PieceMoved(move); bool hasValidMove = this[this.Turn].SelectMany(p => p.GetValidMoves()).Where(m => IsValid(m)).Any(); bool isInCheck = this.IsInCheck(); if (isInCheck && hasValidMove) this.OnCheck(); this.CurrentPlayer.OnTurn(); if (isInCheck && !hasValidMove) this.OnCheckmate(); else if (!isInCheck && !hasValidMove) this.OnStalemate(StalemateReason.NoMoveAvailable); return true; }
public override bool Attacks(Square square, Board board) { return(Attacks(this, square, board)); }
private void OnSquareChanged(Square square) { if (this.SquareChanged != null) this.SquareChanged(square); }
private void listenerSquare(Square sq, bool whiteTurn) { List pWhite = null; List pBlack = null; ImageList iWhite = new ImageList(); ImageList iBlack = new ImageList(); Piece piece = null; if (whiteTurn) { piece = Board.getInstance().consultPiece(sq.getPosition(), true); } else { piece = Board.getInstance().consultPiece(sq.getPosition(), false); } if (piece != null) { if (MainForm.selectedPiece != null) { deletePieceSquare(MainForm.selectedPiece); deleteAllowedMovements(MainForm.selectedPiece.getAllowedMovements()); } MainForm.selectedPiece = piece; paintPiece(MainForm.selectedPiece); paintAllowedMovements(MainForm.selectedPiece.getAllowedMovements()); } else { //Empty square or occupied by an opponent's piece Color turnColor; if (whiteTurn) { turnColor = Color.White; } else { turnColor = Color.Black; } if (MainForm.selectedPiece != null && MainForm.selectedPiece.getColor() == turnColor) { // A piece of the current player is selected Position posIni = MainForm.selectedPiece.getPosition(); Position posFin = sq.getPosition(); Piece deletedPiece = null; //Deleted piece. It is returned in case an undo action is triggered. if (MainForm.selectedPiece.isvalidMove(posFin)) //If the movement is valid ... { if (Caretaker.mementoBoard != null) { pWhite = Caretaker.mementoBoard.getWhitePieces().clone(); pBlack = Caretaker.mementoBoard.getBlackPieces().clone(); } if (Caretaker.mementoImages != null) { foreach (Image i in Caretaker.mementoImages.getWhiteImages().Images) { iWhite.Images.Add(i); } foreach (Image i in Caretaker.mementoImages.getBlackImages().Images) { iBlack.Images.Add(i); } } createMementos(); deletedPiece = realizeMovement(posFin); BoardLogic.updateListAllowedMovements(); bool kingCheck = false; if (whiteTurn) { kingCheck = BoardLogic.isCheck(true); } else { kingCheck = BoardLogic.isCheck(false); } if (kingCheck) { //Undo the movement realizeMovement(posIni); Caretaker.mementoBoard.setWhitePieces(pWhite); Caretaker.mementoBoard.setBlackPieces(pBlack); Caretaker.mementoImages.setWhiteImages(iWhite); Caretaker.mementoImages.setBlackImages(iBlack); if (deletedPiece != null) { //Return the deleted piece if (whiteTurn) { blackPieces.insert(deletedPiece); } else { whitePieces.insert(deletedPiece); } //Delete inserted image if (whiteTurn) { mainForm.deleteLastImage(mainForm.getBlackImages()); } else { mainForm.deleteLastImage(mainForm.getWhiteImages()); } drawPiece(deletedPiece); } MessageBox.Show(this, "Your king would be in check if you carried out this movement", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //The king is not in check int lastRow = -1; if (whiteTurn) { lastRow = 0; } else { lastRow = 7; } if (MainForm.selectedPiece is Pawn && posFin.getRow() == lastRow) { //Promotion FormPromotion f = new FormPromotion(MainForm.selectedPiece as Pawn); f.ShowDialog(); } BoardLogic.updateListAllowedMovements(); bool doCheck; if (whiteTurn) { doCheck = BoardLogic.isCheck(false); } else { doCheck = BoardLogic.isCheck(true); } if (doCheck) { MessageBox.Show(this, "King is in check!", "Check", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } if (deletedPiece != null) { if (whiteTurn) { mainForm.paintDeletedBlackPieces(); } else { mainForm.paintDeletedWhitePieces(); } } mainForm.showInLog(MainForm.selectedPiece.ToString() + " --> " + "From " + posIni.ToString() + " to " + posFin.ToString()); mainForm.enableUndo(); mainForm.shiftTurn(); } } } } }
public PieceMove(Square source, Square target, Type promotePawnTo) { this.Source = source; this.Target = target; this.PawnPromotedTo = promotePawnTo; }
public abstract override bool IsMoveValid(Square dest);
public PossibleMoves(Gamestate board, Square StartPosition) { MoveCount = 0; MoveBitMask = 0; Piece StartPiece = board.GetPiece(StartPosition); if (StartPiece == null) { return; } Moves = StartPiece.getPositionMoves(StartPosition); MoveDirections skipDirection = MoveDirections.Move_0; UInt32 mask = 1; foreach (Move move in Moves) { mask <<= 1; if (move.Direction == skipDirection) { continue; } else { skipDirection = MoveDirections.Move_0; } if (continueIfCastle(board, StartPiece, move)) { continue; } Piece EndPiece = board.GetPiece(move.MovePosition); Piece CapturePiece = board.GetPiece(move.CapturePosition); if (continueIfEnPassant(board, move, CapturePiece)) { continue; } if (endPiecesMatchMoveFlags(StartPiece, move, EndPiece, CapturePiece)) { // check if move is legal Gamestate testBoard = new Gamestate(board); if (testBoard.GetPiece(move.CapturePosition) != null) { testBoard.RemovePiece(move.CapturePosition); } Piece piece = testBoard.GetPiece(StartPosition); testBoard.RemovePiece(StartPosition); testBoard.PutPiece(piece, move.MovePosition); testBoard.turnColor = (testBoard.turnColor == PieceColor.White) ? PieceColor.Black : PieceColor.White; ControlledPositions controlledMoves = new ControlledPositions(testBoard); if (controlledMoves.Check == null) { if (castleSquaresInCheck(move, piece, controlledMoves)) { continue; } EndPositionBitMask |= ((UInt64)1 << (byte)move.MovePosition); MoveBitMask |= mask; MoveCount++; } } if (EndPiece != null || CapturePiece != null) { skipDirection = move.Direction; } } MoveBitMask >>= 1; }
/** * Draws the image for a Piece on top of a Square */ internal void drawPiece(PieceType piece, Square sq) { string[] pieces = { "black_king", "black_queen", "black_rook", "black_bishop", "black_knight", "black_pawn", "white_king", "white_queen", "white_rook", "white_bishop", "white_knight", "white_pawn" }; string pieceString = ""; // Get the Piece String (filename) for the piece given switch (piece) { case PieceType.k: pieceString = "black_king"; break; case PieceType.q: pieceString = "black_queen"; break; case PieceType.r: pieceString = "black_rook"; break; case PieceType.b: pieceString = "black_bishop"; break; case PieceType.n: pieceString = "black_knight"; break; case PieceType.p: pieceString = "black_pawn"; break; case PieceType.K: pieceString = "white_king"; break; case PieceType.Q: pieceString = "white_queen"; break; case PieceType.R: pieceString = "white_rook"; break; case PieceType.B: pieceString = "white_bishop"; break; case PieceType.N: pieceString = "white_knight"; break; case PieceType.P: pieceString = "white_pawn"; break; } if (pieceString.Length == 0) { // None of the above, set as empty and return. sq.setPiece(PieceType.Empty); return; } // From site http://msdn.microsoft.com/en-us/library/vstudio/aa970269(v=vs.100).aspx // Create Image Element Image myImage = new Image(); myImage.Width = 75; // Create source BitmapImage myBitmapImage = new BitmapImage(); // BitmapImage.UriSource must be in a BeginInit/EndInit block myBitmapImage.BeginInit(); myBitmapImage.UriSource = new Uri(App.getPath() + @"Images\PieceImages\" + pieceString + ".png"); myBitmapImage.DecodePixelWidth = 75; if (this.flipped & this.blackReverse & pieceString.StartsWith("b")) { myBitmapImage.Rotation = Rotation.Rotate270; } else if (this.blackReverse & pieceString.StartsWith("b")) { myBitmapImage.Rotation = Rotation.Rotate180; } else if (this.flipped) { myBitmapImage.Rotation = Rotation.Rotate90; } myBitmapImage.EndInit(); myImage.Source = myBitmapImage; myImage.IsHitTestVisible = false; sq.setPieceImage(myImage); sq.setPiece(piece); myImage.SetValue(TextBlock.TextProperty, pieceString); }
public Move(MoveFlags flags, MoveDirections direction, Square startPosition, Square movePosition, Square capturePosition, PieceType conversionType = PieceType.PieceType_NB) { Flags = flags; Direction = direction; StartPosition = startPosition; MovePosition = movePosition; CapturePosition = capturePosition; ConversionType = conversionType; }
public Piece(PlayerColor player, Square square) { this.Player = player; this.Square = square; }
public static void AddPiece(this Game game, Square square, PieceType type) { Piece piece = null; switch (type) { case PieceType.NoPiece: break; case PieceType.WhiteKing: piece = new King(Color.White); break; case PieceType.WhiteQueen: piece = new Queen(Color.White); break; case PieceType.WhiteRook: piece = new Rook(Color.White); break; case PieceType.WhiteBishop: piece = new Bishop(Color.White); break; case PieceType.WhiteNight: piece = new Knight(Color.White); break; case PieceType.WhitePawn: piece = new Pawn(Color.White); break; case PieceType.BlackKing: piece = new King(Color.Black); break; case PieceType.BlackQueen: piece = new Queen(Color.Black); break; case PieceType.BlackRook: piece = new Rook(Color.Black); break; case PieceType.BlackBishop: piece = new Bishop(Color.Black); break; case PieceType.BlackKnight: piece = new Knight(Color.Black); break; case PieceType.BlackPawn: piece = new Pawn(Color.Black); break; default: throw new NotImplementedException(); } game.AddPiece(square.File, square.Rank, piece); }
internal void SetPlacement(Board board, FEN.PiecePlacement piecePlacement) { this.Player = piecePlacement.Player; this.Square = piecePlacement.Square; this.Board = board; }
/** * Performs a move based on the origin and destination squares */ public void MoveHandler(Square orig, Square dest) { PieceType promoteTo = ((dest.getSquareNumber() <= 7 | dest.getSquareNumber() > 55) & (orig.getPiece().Equals(PieceType.p) | orig.getPiece().Equals(PieceType.P))) ? getPromotion(orig.getPiece()) : PieceType.Empty; Move current = new Move(orig.getSquareNumber(), dest.getSquareNumber(), promoteTo); if (MoveCheck(current)) { performMove(current); } }
public static String GetName(Square square) { return square.getName(); }
public Piece.Piece GetPiece(Square square) { return(pieces.FirstOrDefault(p => p.Square == square)); }