SMUnlimited / AMAI

Advanced Melee Artificial Intelligence Mod For Warcraft 3
Other
192 stars 31 forks source link

active expansion Should take effect globally #316

Open jzy-chitong56 opened 1 month ago

jzy-chitong56 commented 1 month ago

This is an oversight At that time, I only considered part of the code

I thought actively expanding would be effective -- https://github.com/SMUnlimited/AMAI/issues/286 However, the effectiveness of Mine3 is only for exp_prepared if mines < 3 and ((ai_time - exp_time_count > exp_second_time) or (active_expansion and ai_time - exp_time_count > exp_first_time)) then

Therefore, in the code, active expansion is always prioritized by the first two and cannot take effect

  if mines < 1 or gold_left < 2500 then
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_emergency_prio)
  elseif rebuild or upkeepboost then
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_rebuild_prio)
  else
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_prio)
  endif

So I think we should add a parameter

Add a value to all expansions, which can be calculated using the number of gold mines

if active_expansion then
  set i = Max(GetPlayerUnitTypeCount(Player(PLAYER_NEUTRAL_PASSIVE),'ngol') - (c_enemy_total + c_ally_total + 1), 20)
endif

  if mines < 1 or gold_left < 2500 then
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_emergency_prio + i)
  elseif rebuild or upkeepboost then
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_rebuild_prio + i)
  else
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_prio + i)
  endif

Additionally, I have a more outrageous piece of code here, which is chaotic expanding

if mines < 1 or gold_left < 2500 or exp_prepared then
  call Trace("ExpansionBuilder: Putting mine on build list")
  if mines < 1 or gold_left < 2500 then
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_emergency_prio + i)
  elseif rebuild or upkeepboost then
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_rebuild_prio + i)
  else
    call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_prio + i)
  endif
elseif active_expansion and GetNextExpansion() >= 0 and GetExpansionFoe() == null and HallsCompleted(racial_expansion) and mines < 4 and GetRandomInt(0, 100 - i) < 48 and GetGold() > 1000 and GetWood() > 700 and not CheckDoubleExpansionsClaimedInArea(I2R(GetExpansionX()), I2R(GetExpansionY()), false) then
  set u = GetExpansionPeon()
  if u != null and u != expansion_peon and not_taken_expansion == null then
    call SetExpansion(u, old_id[racial_expansion])
    call CreateDebugTag("chaos expansion", 10, u, 3.00, 1.50)
  endif
  set u = null
endif