load("//tools:copts.bzl", "COPTS")

cc_library(
    name = "ai_common_types",
    hdrs = ["AICommonTypes.hpp"],
    copts = COPTS,
    visibility = ["//visibility:public"],
    deps = [
        "//src/main/cpp/net/eagle0/shardok/library:battalion_type",
        "//src/main/cpp/net/eagle0/shardok/library:shardok_c_types",
    ],
)

cc_library(
    name = "ai_attacker_strategy_selector",
    srcs = ["AIAttackerStrategySelector.cpp"],
    hdrs = ["AIAttackerStrategySelector.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        ":ai_attack_locations",
        ":ai_flee_decision_calculator",
        ":ai_score_utilities",
        ":ai_strategy",
        ":ai_water_crossing_command_chooser",
        "//src/main/cpp/net/eagle0/shardok/library/map:coords_set",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:game_state_cc_fbs",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:victory_condition_cc_fbs",
    ],
)

cc_library(
    name = "ai_attack_groups",
    srcs = ["AIAttackGroups.cpp"],
    hdrs = ["AIAttackGroups.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai:__subpackages__",
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        ":ai_attack_locations",
        ":ai_common_types",
        ":ai_score_utilities",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:hex_map_cc_fbs",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:unit_cc_fbs",
    ],
)

cc_library(
    name = "ai_attack_locations",
    srcs = ["AIAttackLocations.cpp"],
    hdrs = ["AIAttackLocations.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai:__subpackages__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        ":ai_score_utilities",
        "//src/main/cpp/net/eagle0/shardok/library/map:terrain",
        "//src/main/cpp/net/eagle0/shardok/library/settings:game_settings",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:hex_map_cc_fbs",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:unit_cc_fbs",
    ],
)

cc_library(
    name = "ai_defender_strategy_selector",
    srcs = ["AIDefenderStrategySelector.cpp"],
    hdrs = ["AIDefenderStrategySelector.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        ":ai_attack_locations",
        ":ai_score_utilities",
        ":ai_strategy",
        ":ai_water_crossing_calculator",
        "//src/main/cpp/net/eagle0/shardok/library:game_state_w",
        "//src/main/cpp/net/eagle0/shardok/library/map:coords_set",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:game_state_cc_fbs",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:victory_condition_cc_fbs",
    ],
)

cc_library(
    name = "ai_distance_debuf",
    srcs = ["AIDistanceDebuf.cpp"],
    hdrs = ["AIDistanceDebuf.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai:__subpackages__",
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        ":ai_attack_locations",
        ":ai_common_types",
        ":ai_score_utilities",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
        "//src/main/cpp/net/eagle0/shardok/library/settings:game_settings",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:hex_map_cc_fbs",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:unit_cc_fbs",
    ],
)

cc_library(
    name = "ai_minimum_distance_and_target",
    srcs = ["AIMinimumDistanceAndTarget.cpp"],
    hdrs = ["AIMinimumDistanceAndTarget.hpp"],
    copts = COPTS,
    visibility = ["//visibility:public"],
    deps = [
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
    ],
)

cc_library(
    name = "ai_score_utilities",
    srcs = ["AIScoreUtilities.cpp"],
    hdrs = ["AIScoreUtilities.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai:__subpackages__",
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        "//src/main/cpp/net/eagle0/shardok/library:game_state_w",
        "//src/main/cpp/net/eagle0/shardok/library:shardok_c_types",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:game_state_cc_fbs",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:unit_cc_fbs",
    ],
)

cc_library(
    name = "ai_flee_decision_calculator",
    srcs = ["AIFleeDecisionCalculator.cpp"],
    hdrs = ["AIFleeDecisionCalculator.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
    ],
    deps = [
        ":ai_score_utilities",
        ":ai_unit_score_calculator",
        "//src/main/cpp/net/eagle0/shardok/library:engine",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
    ],
)

cc_library(
    name = "ai_heuristic_weighting",
    srcs = ["AIHeuristicWeighting.cpp"],
    hdrs = ["AIHeuristicWeighting.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai/mcts/adapters:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
    ],
    deps = [
        "//src/main/cpp/net/eagle0/shardok/library:game_state_w",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
        "//src/main/cpp/net/eagle0/shardok/library/map:coords_set",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
        "//src/main/protobuf/net/eagle0/shardok/common:command_type_cc_proto",
    ],
)

cc_library(
    name = "ai_command_evaluator",
    srcs = ["AICommandEvaluator.cpp"],
    hdrs = ["AICommandEvaluator.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
    ],
    deps = [
        ":ai_command_filter",
        ":ai_strategy",
        ":transposition_table",
        "//src/main/cpp/net/eagle0/common:sequence_random_generator",
        "//src/main/cpp/net/eagle0/shardok/ai/score:ai_score_calculator_interface",
        "//src/main/cpp/net/eagle0/shardok/library:engine",
        "//src/main/cpp/net/eagle0/shardok/library:game_state_w",
        "//src/main/cpp/net/eagle0/shardok/library/map:coords_set",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_cube_utils",
        "//src/main/protobuf/net/eagle0/shardok/common:command_type_cc_proto",
    ],
)

cc_library(
    name = "ai_command_filter",
    srcs = ["AICommandFilter.cpp"],
    hdrs = ["AICommandFilter.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai/mcts:__pkg__",
        "//src/main/cpp/net/eagle0/shardok/ai/mcts/adapters:__pkg__",
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
    ],
    deps = [
        ":ai_common_types",
        "//src/main/cpp/net/eagle0/shardok/library:engine",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
        "//src/main/cpp/net/eagle0/shardok/library/settings:game_settings",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:game_state_cc_fbs",
        "//src/main/protobuf/net/eagle0/shardok/common:command_type_cc_proto",
    ],
)

cc_library(
    name = "transposition_table",
    srcs = ["TranspositionTable.cpp"],
    hdrs = ["TranspositionTable.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
    ],
    deps = [
        "//src/main/cpp/net/eagle0/shardok/library:game_state_w",
    ],
)

cc_library(
    name = "ai_strategy",
    srcs = ["AIStrategy.cpp"],
    hdrs = ["AIStrategy.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai:__subpackages__",
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        ":ai_attack_groups",
        "//src/main/cpp/net/eagle0/shardok/library/map:coords_set",
    ],
)

cc_library(
    name = "ai_unit_score_calculator",
    srcs = ["AIUnitScoreCalculator.cpp"],
    hdrs = ["AIUnitScoreCalculator.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai:__subpackages__",
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        ":ai_attack_locations",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
    ],
)

cc_library(
    name = "ai_water_crossing_calculator",
    srcs = ["AIWaterCrossingCalculator.cpp"],
    hdrs = ["AIWaterCrossingCalculator.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok:__pkg__",
        "//src/main/cpp/net/eagle0/shardok/ai:__subpackages__",
        "//src/test/cpp/net/eagle0/shardok/ai:__subpackages__",
    ],
    deps = [
        ":ai_common_types",
        ":ai_minimum_distance_and_target",
        "//src/main/cpp/net/eagle0/shardok/ai/score:ai_score_calculator_interface",
        "//src/main/cpp/net/eagle0/shardok/library:game_state_w",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
        "//src/main/cpp/net/eagle0/shardok/library/fb_helpers:hex_map_helpers",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:game_state_cc_fbs",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:hex_map_cc_fbs",
    ],
)

cc_library(
    name = "ai_water_crossing_command_chooser",
    srcs = ["AIWaterCrossingCommandChooser.cpp"],
    hdrs = ["AIWaterCrossingCommandChooser.hpp"],
    copts = COPTS,
    visibility = ["//visibility:public"],
    deps = [
        ":ai_minimum_distance_and_target",
        ":ai_water_crossing_calculator",
        "//src/main/cpp/net/eagle0/shardok/library:game_state_w",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
    ],
)

cc_library(
    name = "ai_time_budget",
    srcs = ["AITimeBudget.cpp"],
    hdrs = ["AITimeBudget.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai/mcts:__pkg__",
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
    ],
    deps = [
        "//src/main/cpp/net/eagle0/shardok/library:game_state_w",
        "//src/main/cpp/net/eagle0/shardok/library/settings:game_settings",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_cube_utils",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
        "//src/main/flatbuffer/net/eagle0/shardok/storage:game_state_cc_fbs",
    ],
)

cc_library(
    name = "ai_iterative_deepening",
    srcs = ["IterativeDeepeningAI.cpp"],
    hdrs = ["IterativeDeepeningAI.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai/mcts:__pkg__",
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
    ],
    deps = [
        ":ai_attacker_strategy_selector",
        ":ai_command_evaluator",
        ":ai_defender_strategy_selector",
        ":ai_time_budget",
        ":ai_water_crossing_command_chooser",
        "//src/main/cpp/net/eagle0/common:time_utils",
        "//src/main/cpp/net/eagle0/shardok/ai/score:ai_score_calculator_interface",
        "//src/main/cpp/net/eagle0/shardok/library:engine",
        "//src/main/cpp/net/eagle0/shardok/library/util:hex_map_utils",
    ],
)

cc_library(
    name = "ai_config",
    hdrs = ["AIConfig.hpp"],
    copts = COPTS,
    visibility = [
        "//src/main/cpp/net/eagle0/shardok/ai_performance_runner:__pkg__",
        "//src/test/cpp/net/eagle0/shardok/ai:__pkg__",
    ],
)

cc_library(
    name = "shardok_ai_client",
    srcs = ["ShardokAIClient.cpp"],
    hdrs = ["ShardokAIClient.hpp"],
    copts = COPTS,
    visibility = ["//visibility:public"],
    deps = [
        ":ai_attacker_strategy_selector",
        ":ai_config",
        ":ai_defender_strategy_selector",
        ":ai_flee_decision_calculator",
        ":ai_iterative_deepening",  # Direct dependency for runtime selection
        ":ai_time_budget",
        ":ai_water_crossing_command_chooser",
        "//src/main/cpp/net/eagle0/common:time_utils",
        "//src/main/cpp/net/eagle0/shardok/ai/mcts:shardok_mcts_ai",  # MCTS with abstraction layer
        "//src/main/cpp/net/eagle0/shardok/ai/score:ai_score_calculator_interface",
        "//src/main/cpp/net/eagle0/shardok/ai/score:mcts_optimized_ai_score_calculator",  # Bounded linear scorer for MCTS
        "//src/main/cpp/net/eagle0/shardok/ai/score:normalized_ai_score_calculator",  # Normalized [0,1] scorer for ML training
        "//src/main/cpp/net/eagle0/shardok/ai/score:standard_ai_score_calculator",  # Standard unbounded scorer (default)
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances",
        "//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
        "//src/main/cpp/net/eagle0/shardok/library/util:game_state_dumper",
        "@com_google_protobuf//:protobuf",
    ],
)
