public void Reset(PlayerPieceSet white_pieces, PlayerPieceSet black_pieces, Players player_to_move, Castle white_castling_options, Castle black_castling_options, int? capture_en_passant_column, ushort fullmove_number, ushort halfmove_clock) { Debug.Assert(white_pieces != null); Debug.Assert(black_pieces != null); Debug.Assert(m_white_pieces == null); Debug.Assert(m_black_pieces == null); m_white_pieces = white_pieces; m_black_pieces = black_pieces; m_position_flags.Clear(); if (player_to_move == Players.White) { m_position_flags.SetBit(BIT_WHITE_TO_MOVE); } // TODO - HasFlag is known to be slow, consider optimizing SetCanCastleShort(Players.White, white_castling_options.HasFlag(Castle.Short)); SetCanCastleLong(Players.White, white_castling_options.HasFlag(Castle.Long)); SetCanCastleShort(Players.Black, black_castling_options.HasFlag(Castle.Short)); SetCanCastleLong(Players.Black, black_castling_options.HasFlag(Castle.Long)); CaptureEnPassantColumn = capture_en_passant_column; FullmoveNumber = fullmove_number; HalfmoveClock = halfmove_clock; }