//
// Shardok-specific MCTS AI that wraps the abstract implementation
//

#ifndef EAGLE0_SHARDOK_AI_MCTS_SHARDOK_MCTSAI_HPP
#define EAGLE0_SHARDOK_AI_MCTS_SHARDOK_MCTSAI_HPP

#include <memory>
#include <vector>

#include "adapters/ShardokMCTSFactory.hpp"
#include "src/main/cpp/net/eagle0/common/mcts/abstract/AbstractMCTSAI.hpp"
#include "src/main/cpp/net/eagle0/shardok/ai/AIStrategy.hpp"
#include "src/main/cpp/net/eagle0/shardok/ai/AITimeBudget.hpp"
#include "src/main/cpp/net/eagle0/shardok/ai/IterativeDeepeningAI.hpp"  // For SearchResult compatibility
#include "src/main/cpp/net/eagle0/shardok/library/GameStateW.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCTypes.h"
#include "src/main/cpp/net/eagle0/shardok/library/action_point_distances/ActionPointDistancesCache.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
#pragma clang diagnostic pop

namespace shardok {

// Forward declarations
class ShardokEngine;
class AICommandFilter;
class AIScoreCalculator;

class ShardokMCTSAI {
public:
    using SearchResult = IterativeDeepeningAI::SearchResult;
    using MCTSConfig = mcts::MCTSConfig;

    ShardokMCTSAI(
            PlayerId playerId,
            bool isDefender,
            AIStrategy strategy,
            const CoordsSet& castleCoords,
            const AIScoreCalculator& scoreCalculator,
            const APDCache& apdCache,
            const ALCache& alCache,
            MCTSConfig config = MCTSConfig{});

    // Main search interface - compatible with IterativeDeepeningAI
    [[nodiscard]] auto Search(
            const GameSettingsSPtr& settings,
            const GameStateW& state,
            const AITimeBudget& budget) const -> SearchResult;

    // Configuration
    [[nodiscard]] auto GetConfig() const -> const MCTSConfig& { return abstractAI_->GetConfig(); }
    void SetConfig(const MCTSConfig& newConfig) { abstractAI_->SetConfig(newConfig); }

private:
    std::unique_ptr<mcts::AbstractMCTSAI> abstractAI_;

    // Shardok-specific context
    bool isDefender_;
    AIStrategy strategy_;
    const CoordsSet& castleCoords_;
    const AIScoreCalculator& scoreCalculator_;
    const APDCache& apdCache_;
    const ALCache& alCache_;
};

}  // namespace shardok

#endif  // EAGLE0_SHARDOK_AI_MCTS_SHARDOK_MCTSAI_HPP
