Manages when to build your buildings
| 923 | |
| 924 | //Manages when to build your buildings |
| 925 | void ProtossMultiplayerBot::BuildOrder() { |
| 926 | const ObservationInterface* observation = Observation(); |
| 927 | size_t gateway_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_GATEWAY) + CountUnitType(observation,UNIT_TYPEID::PROTOSS_WARPGATE); |
| 928 | size_t cybernetics_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_CYBERNETICSCORE); |
| 929 | size_t forge_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_FORGE); |
| 930 | size_t twilight_council_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_TWILIGHTCOUNCIL); |
| 931 | size_t templar_archive_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_TEMPLARARCHIVE); |
| 932 | size_t base_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_NEXUS); |
| 933 | size_t robotics_facility_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_ROBOTICSFACILITY); |
| 934 | size_t robotics_bay_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_ROBOTICSBAY); |
| 935 | size_t stargate_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_STARGATE); |
| 936 | size_t fleet_beacon_count = CountUnitType(observation, UNIT_TYPEID::PROTOSS_FLEETBEACON); |
| 937 | |
| 938 | // 3 Gateway per expansion |
| 939 | if (gateway_count < std::min<size_t>(2 * base_count, 7)) { |
| 940 | |
| 941 | //If we have 1 gateway, prioritize building CyberCore |
| 942 | if (cybernetics_count < 1 && gateway_count > 0) { |
| 943 | TryBuildStructureNearPylon(ABILITY_ID::BUILD_CYBERNETICSCORE, UNIT_TYPEID::PROTOSS_PROBE); |
| 944 | return; |
| 945 | } |
| 946 | else { |
| 947 | //If we have 1 gateway Prioritize getting another expansion out before building more gateways |
| 948 | if (base_count < 2 && gateway_count > 0) { |
| 949 | TryBuildExpansionNexus(); |
| 950 | return; |
| 951 | } |
| 952 | |
| 953 | if (observation->GetFoodWorkers() >= target_worker_count_ && observation->GetMinerals() > 150 + (100 * gateway_count)) { |
| 954 | TryBuildStructureNearPylon(ABILITY_ID::BUILD_GATEWAY, UNIT_TYPEID::PROTOSS_PROBE); |
| 955 | } |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | if (cybernetics_count > 0 && forge_count < 2) { |
| 960 | TryBuildStructureNearPylon(ABILITY_ID::BUILD_FORGE, UNIT_TYPEID::PROTOSS_PROBE); |
| 961 | } |
| 962 | |
| 963 | //go stargate or robo depending on build |
| 964 | if (air_build_) { |
| 965 | if (gateway_count > 1 && cybernetics_count > 0) { |
| 966 | if (stargate_count < std::min<size_t>(base_count, 5)) { |
| 967 | if (observation->GetMinerals() > 150 && observation->GetVespene() > 150) { |
| 968 | TryBuildStructureNearPylon(ABILITY_ID::BUILD_STARGATE, UNIT_TYPEID::PROTOSS_PROBE); |
| 969 | } |
| 970 | } |
| 971 | else if (stargate_count > 0 && fleet_beacon_count < 1) { |
| 972 | if (observation->GetMinerals() > 300 && observation->GetVespene() > 200) { |
| 973 | TryBuildStructureNearPylon(ABILITY_ID::BUILD_FLEETBEACON, UNIT_TYPEID::PROTOSS_PROBE); |
| 974 | } |
| 975 | } |
| 976 | } |
| 977 | } |
| 978 | else { |
| 979 | if (gateway_count > 2 && cybernetics_count > 0) { |
| 980 | if (robotics_facility_count < std::min<size_t>(base_count, 4)) { |
| 981 | if (observation->GetMinerals() > 200 && observation->GetVespene() > 100) { |
| 982 | TryBuildStructureNearPylon(ABILITY_ID::BUILD_ROBOTICSFACILITY, UNIT_TYPEID::PROTOSS_PROBE); |
nothing calls this directly
no test coverage detected