/// <summary> /// Static constructor that insures that only one instance of FlyweightPieceFactory exists. /// </summary> /// <returns>Returns the singelton instance of the FlyweightPieceFactory.</returns> public static FlyweightPieceFactory Instance() { if (m_singelton == null) m_singelton = new FlyweightPieceFactory(); return m_singelton; }
/// <summary> /// Static constructor that insures that only one instance of FlyweightPieceFactory exists. /// </summary> /// <returns>Returns the singelton instance of the FlyweightPieceFactory.</returns> public static FlyweightPieceFactory Instance() { if (m_singelton == null) { m_singelton = new FlyweightPieceFactory(); } return(m_singelton); }
public Board(Board board) { m_squares = new Piece[board.m_squares.Length]; for (int i = 0; i < m_squares.Length; ++i) { m_squares[i] = board.m_squares[i]; } m_state = board.m_state; m_history = new HashHistory(board.m_history); m_pieceFactory = FlyweightPieceFactory.Instance(); m_whiteLocationList = new PieceLocationManager(board.m_whiteLocationList); m_blackLocationList = new PieceLocationManager(board.BlackPieceLocations); m_whiteKingLocation = board.m_whiteKingLocation; m_blackKingLocation = board.m_blackKingLocation; m_boardHash = new ZobristHash(board.m_boardHash); }
public Board(Board board) { m_squares = new Piece[board.m_squares.Length]; for (int i = 0; i < m_squares.Length; ++i) m_squares[i] = board.m_squares[i]; m_state = board.m_state; m_history = new HashHistory(board.m_history); m_pieceFactory = FlyweightPieceFactory.Instance(); m_whiteLocationList = new PieceLocationManager(board.m_whiteLocationList); m_blackLocationList = new PieceLocationManager(board.BlackPieceLocations); m_whiteKingLocation = board.m_whiteKingLocation; m_blackKingLocation = board.m_blackKingLocation; m_boardHash = new ZobristHash(board.m_boardHash); }
/// <summary> /// Initializes a new instance of Board ready to be played on /// and with pieces put on their initial locations. /// </summary> public Board() { //we make board twice as big as we use the 0x88 scheme for representing the board m_squares = new Piece[NOF_SQUARS]; for (int i = 0; i < m_squares.Length; ++i) m_squares[i] = Piece.None; m_squares[(int)Square.A1] = Piece.WhiteRook; m_squares[(int)Square.B1] = Piece.WhiteKnight; m_squares[(int)Square.C1] = Piece.WhiteBishop; m_squares[(int)Square.D1] = Piece.WhiteQueen; m_squares[(int)Square.E1] = Piece.WhiteKing; m_squares[(int)Square.F1] = Piece.WhiteBishop; m_squares[(int)Square.G1] = Piece.WhiteKnight; m_squares[(int)Square.H1] = Piece.WhiteRook; m_squares[(int)Square.A2] = Piece.WhitePawn; m_squares[(int)Square.B2] = Piece.WhitePawn; m_squares[(int)Square.C2] = Piece.WhitePawn; m_squares[(int)Square.D2] = Piece.WhitePawn; m_squares[(int)Square.E2] = Piece.WhitePawn; m_squares[(int)Square.F2] = Piece.WhitePawn; m_squares[(int)Square.G2] = Piece.WhitePawn; m_squares[(int)Square.H2] = Piece.WhitePawn; m_squares[(int)Square.A7] = Piece.BlackPawn; m_squares[(int)Square.B7] = Piece.BlackPawn; m_squares[(int)Square.C7] = Piece.BlackPawn; m_squares[(int)Square.D7] = Piece.BlackPawn; m_squares[(int)Square.E7] = Piece.BlackPawn; m_squares[(int)Square.F7] = Piece.BlackPawn; m_squares[(int)Square.G7] = Piece.BlackPawn; m_squares[(int)Square.H7] = Piece.BlackPawn; m_squares[(int)Square.A8] = Piece.BlackRook; m_squares[(int)Square.B8] = Piece.BlackKnight; m_squares[(int)Square.C8] = Piece.BlackBishop; m_squares[(int)Square.D8] = Piece.BlackQueen; m_squares[(int)Square.E8] = Piece.BlackKing; m_squares[(int)Square.F8] = Piece.BlackBishop; m_squares[(int)Square.G8] = Piece.BlackKnight; m_squares[(int)Square.H8] = Piece.BlackRook; m_state.ColorToPlay = PieceColor.White; m_state.WhiteCanCastleShort = true; m_state.WhiteCanCastleLong = true; m_state.BlackCanCastleShort = true; m_state.BlackCanCastleLong = true; m_state.EnPassantTarget = Square.None; m_state.NonHitAndPawnMovesPlayed = 0; m_history = new HashHistory(); m_pieceFactory = FlyweightPieceFactory.Instance(); m_whiteLocationList = new PieceLocationManager(); m_blackLocationList = new PieceLocationManager(); foreach (Square square in this) { if (GetPieceColor(square) == PieceColor.White) m_whiteLocationList.PlacePiece(square); if (GetPieceColor(square) == PieceColor.Black) m_blackLocationList.PlacePiece(square); } m_whiteKingLocation = Square.E1; m_blackKingLocation = Square.E8; m_boardHash = new ZobristHash(this); AddToHistory(); }
/// <summary> /// Initializes a new instance of Board ready to be played on /// and with pieces put on their initial locations. /// </summary> public Board() { //we make board twice as big as we use the 0x88 scheme for representing the board m_squares = new Piece[NOF_SQUARS]; for (int i = 0; i < m_squares.Length; ++i) { m_squares[i] = Piece.None; } m_squares[(int)Square.A1] = Piece.WhiteRook; m_squares[(int)Square.B1] = Piece.WhiteKnight; m_squares[(int)Square.C1] = Piece.WhiteBishop; m_squares[(int)Square.D1] = Piece.WhiteQueen; m_squares[(int)Square.E1] = Piece.WhiteKing; m_squares[(int)Square.F1] = Piece.WhiteBishop; m_squares[(int)Square.G1] = Piece.WhiteKnight; m_squares[(int)Square.H1] = Piece.WhiteRook; m_squares[(int)Square.A2] = Piece.WhitePawn; m_squares[(int)Square.B2] = Piece.WhitePawn; m_squares[(int)Square.C2] = Piece.WhitePawn; m_squares[(int)Square.D2] = Piece.WhitePawn; m_squares[(int)Square.E2] = Piece.WhitePawn; m_squares[(int)Square.F2] = Piece.WhitePawn; m_squares[(int)Square.G2] = Piece.WhitePawn; m_squares[(int)Square.H2] = Piece.WhitePawn; m_squares[(int)Square.A7] = Piece.BlackPawn; m_squares[(int)Square.B7] = Piece.BlackPawn; m_squares[(int)Square.C7] = Piece.BlackPawn; m_squares[(int)Square.D7] = Piece.BlackPawn; m_squares[(int)Square.E7] = Piece.BlackPawn; m_squares[(int)Square.F7] = Piece.BlackPawn; m_squares[(int)Square.G7] = Piece.BlackPawn; m_squares[(int)Square.H7] = Piece.BlackPawn; m_squares[(int)Square.A8] = Piece.BlackRook; m_squares[(int)Square.B8] = Piece.BlackKnight; m_squares[(int)Square.C8] = Piece.BlackBishop; m_squares[(int)Square.D8] = Piece.BlackQueen; m_squares[(int)Square.E8] = Piece.BlackKing; m_squares[(int)Square.F8] = Piece.BlackBishop; m_squares[(int)Square.G8] = Piece.BlackKnight; m_squares[(int)Square.H8] = Piece.BlackRook; m_state.ColorToPlay = PieceColor.White; m_state.WhiteCanCastleShort = true; m_state.WhiteCanCastleLong = true; m_state.BlackCanCastleShort = true; m_state.BlackCanCastleLong = true; m_state.EnPassantTarget = Square.None; m_state.NonHitAndPawnMovesPlayed = 0; m_history = new HashHistory(); m_pieceFactory = FlyweightPieceFactory.Instance(); m_whiteLocationList = new PieceLocationManager(); m_blackLocationList = new PieceLocationManager(); foreach (Square square in this) { if (GetPieceColor(square) == PieceColor.White) { m_whiteLocationList.PlacePiece(square); } if (GetPieceColor(square) == PieceColor.Black) { m_blackLocationList.PlacePiece(square); } } m_whiteKingLocation = Square.E1; m_blackKingLocation = Square.E8; m_boardHash = new ZobristHash(this); AddToHistory(); }