SMUnlimited / AMAI

Advanced Melee Artificial Intelligence Mod For Warcraft 3
Other
207 stars 34 forks source link

ELF build bug #120

Closed jzy-chitong56 closed 11 months ago

jzy-chitong56 commented 1 year ago

if game is Just started

ELF need build racial_farm , if Insufficient resources , then ELF will Wait until resources are sufficient , No further training or build during this period , but now AI have gold , should training peon see the picture just 2 no 1 or 0 (use DisplayTimedTextToPlayer), and wood is 30 , Every test doesn't start until wood have 40 , racial_farm is 40 wood

in my code , if no 0 or 1 , they tell me no run the OneBuildLoopAM loop , maybe is exitwhen index >= build_length , exit the loop , but why index >= build_length , if have 2 , index next run is 0 , and build_length is no 0 (no show 3), and not run InitBuildArrayAM (no show 4)

The problem is , when [exitwhen ret == NOT_ENOUGH_RES] , code will set next build [set build_qty[index_free] = build_qty[index]] , but the no resources unit Still in queue

the [ if ret == CANNOT_BUILD or ret == BUILT_SOME or ret == NOT_ENOUGH_RES or (ret == BUILT_ALL and qty < build_qty[index]) then] can not work ,ret == NOT_ENOUGH_RES now is end the loop ,maybe is bug

fix key maybe is set index = index + 1

so i will Remove it ,if no gold_buffer and wood_buffer , let code build next unit , This is particularly important at the beginning of the game

or

on the the beginning of the game(not hero1) , no exit the loop ,just build next

or

fix the bug and set build next unit

QQ图片20230622192724

this code

` function OneBuildLoopAM takes nothing returns nothing

local integer index = 0
local integer index_free = 0
local integer qty = 0
local integer id = 0
local integer tp = 0
local integer ret = 0
local integer town = 0
local integer array max_order
local integer mo = 0
local integer traced = 0
local integer tracedsome = 0
local integer tracednoresources = 0
local integer tracedall = 0
local string logtype = null
call InitLastUpkeep()
call TimeKeeper()
call CheckTownBuilt()
call SetBuildFree()
call FarmBuilder()
call PeonBuilder()
if not campaign_ai then
  call ExpansionBuilder()
  call HeroReviver()
endif
if tavernguarded == 0 and nearest_neutral[NEUTRAL_TAVERN] != null then
  if neutral_guarded[NEUTRAL_TAVERN] and not hero_built[1] then  //guarantee to train Ownrace hero at the first time
    set recalculate_heros = true
  endif
  set tavernguarded = 1
endif
set total_gold   = GetGold() - gold_buffer
set total_wood   = GetWood() - wood_buffer
set total_food   = ver_food_limit - FoodUsed()
call CheckUpkeepAllowed(ver_food_limit - total_food)
set blocked_gold = 0
set blocked_wood = 0
set blocked_food = 0
set t_build_length = 0
call GetBuildLock()
loop
    exitwhen index >= build_length
    set id = build_item[index]
    set qty = RBlockListCheck(build_qty[index], id)
    set tp = build_type[index]
    set town = Max(build_town[index],0)
    set mo = max_order[id + town*OBJECT_NUM]
    if build_qty[index] > mo then
      if tp == BUILD_UNIT then
          set logtype = "unit "
          set ret = StartUnitAM(qty,id,build_town[index], build_loc[index], build_prio[index], mo)
      elseif tp == BUILD_UPGRADE then
          set logtype = "upgrade "
          set ret = StartUpgradeAM(qty,id)
      elseif tp == BUILD_EXPAND then
          set logtype = "expand "
          set ret = StartExpansionAM(qty,id)
      elseif tp == BUILD_ITEM then
          set logtype = "item "
          set ret = StartItem(qty,id)
      else
        set logtype = "unknown:" + Int2Str(tp)
      endif
      if qty > mo then
        set max_order[id + town*OBJECT_NUM] = qty
      endif
      if ret == CANNOT_BUILD then
        if (traced == 0) then
          call Trace("CANNOT BUILD " + logtype + unitNames[id] + " " + Int2Str(id))
          set traced = id
        endif
        call AddRefresh(tp, qty, id, build_town[index], build_loc[index], build_prio[index])
      elseif ret == BUILT_SOME and tracedsome == 0 then
        //call Trace("BUILT SOME " + logtype + unitNames[id] + " " + Int2Str(id))
        set tracedsome = id
      elseif ret == BUILT_ALL and tracedall == 0 then
        //call Trace("BUILT ALL " + logtype + unitNames[id] + " " + Int2Str(id))
        set tracedall = id
      elseif ret == NOT_ENOUGH_RES and tracednoresources == 0 then
        call Trace("NO RESOURCES " + logtype + unitNames[id] + " " + Int2Str(id))
        set tracednoresources = id
      endif
      exitwhen ret == NOT_ENOUGH_RES // Don't try and build anything else as thing we trying to buy is too expensive
      if ret == CANNOT_BUILD or ret == BUILT_SOME or ret == NOT_ENOUGH_RES or (ret == BUILT_ALL and qty < build_qty[index]) then
        set build_qty[index_free] = build_qty[index]
        set build_type[index_free] = build_type[index]
        set build_item[index_free] = build_item[index]
        set build_loc[index_free] = build_loc[index]
        set build_town[index_free] = build_town[index]
        set build_prio[index_free] = build_prio[index] + prio_t_inc
        set index_free = index_free + 1
      endif
  call DisplayTimedTextToPlayer(Player(0),0,0,15,"0")
      call ApplyUpkeepSaving()
    endif
  call DisplayTimedTextToPlayer(Player(0),0,0,15,"1")
    set index = index + 1
    set total_gold = total_gold - blocked_gold
    set total_wood = total_wood - blocked_wood
    //set total_food = total_food - blocked_food
    set blocked_gold = 0
    set blocked_wood = 0
    set blocked_food = 0
    call UpdateLastUpkeep()
endloop
  call DisplayTimedTextToPlayer(Player(0),0,0,15,"2")
if build_length == 0 then
    call DisplayTimedTextToPlayer(Player(0),0,0,15,"3")
endif
loop
      exitwhen index >= build_length
      set build_qty[index_free] = build_qty[index]
      set build_type[index_free] = build_type[index]
      set build_item[index_free] = build_item[index]
      set build_town[index_free] = build_town[index]
      set build_loc[index_free] = build_loc[index]
      set build_prio[index_free] = build_prio[index] + prio_t_inc
      set index_free = index_free + 1
      set index = index + 1
endloop
set build_length = index_free
call ResetUpkeepSaveTime()
call ReleaseBuildLock()
call RefreshAllNeeded()
call FactoryNumberUpdate()
set logtype = null

endfunction `

function BuildLoopAM takes nothing returns nothing
  local integer blc = 0
  call OneBuildLoopAM()
  call StaggerSleep(1,5)
  loop
      //call Trace("Build Loop")
      set blc = blc + 1
      call OneBuildLoopAM()
      exitwhen player_defeated
      if blc > build_array_reset_time then
          call DisplayTimedTextToPlayer(Player(0),0,0,15,"4")
        call InitBuildArrayAM()
        set blc = 0
      endif
      call Sleep(5 * sleep_multiplier)
  endloop
endfunction
YouMoMCallME commented 1 year ago

Hello Thank you for your support Amai ! I play a lot with your AI v2.6.2 (Warcraft 3 TFT 1.28) I saw that you develop Amai v2.6.2cn I only could find this version on pan.xunlei which unfortunately is not available in my country :(

Would you share with me the latest version of Amai v2.6.2cn (Warcraft 3 TFT 1.28) I really want to play :) I only play Warcraft 3 TFT 1.28 I don't play the Reforge version .

P.S Amai 2.6.2 at github outdated :(

jzy-chitong56 commented 1 year ago

That's right, all online drives in China are not designed for international use,I don't know why your use of git would timeout,You can search for accelerators made by you domestic developers on Git

I don't have the energy to maintain too many links, sorry I hope this translation expresses what I want to say

YouMoMCallME commented 1 year ago

That's right, all online drives in China are not designed for international use,I don't know why your use of git would timeout,You can search for accelerators made by you domestic developers on Git

I don't have the energy to maintain too many links, sorry I hope this translation expresses what I want to say

Can you at least share version 2.6.2cn here on github ? So that 2.6.2cn can be downloaded right here in the Releases list You can share the new version 2.6.2cn with me in Discord (If you have Discord) My Discord : youmomcallme

jzy-chitong56 commented 1 year ago

I often make changes, so I don't like Releases 

Of course, I haven't operated Releases Message ID: @.***>

We need to study it

YouMoMCallME commented 1 year ago

I often make changes, so I don't like Releases  Of course, I haven't operated Releases Message ID: @.***> We need to study it

Can you please release at least an intermediate version. I understand that you are constantly making changes to the mod but it can continue indefinitely :)

jzy-chitong56 commented 1 year ago

https://github.com/jzy-chitong56/AMAI/releases/tag/2.6.2cn

YouMoMCallME commented 1 year ago

https://github.com/jzy-chitong56/AMAI/releases/tag/2.6.2cn

I do not start the map with AMAI :(

I installed your version of the mod . I play Warcraft 3 1.28.

AMAI 2.6.2cn compatible with Warcraft 3 1.28 ?

First I clicked MakeTFT.bat (Created the AI files) and then AMAI.exe (installed Amai on the map Warcraft 3 1.28) and it does not work for some reason :( Error Cannot Load Map Data

AMAI version 2.6.2 works fine. But the new version of AMAI 2.6.2cn does not work.

jzy-chitong56 commented 1 year ago

I have tried and the compilation is normal. You may need to use his new installer

Message ID: @.***>

YouMoMCallME commented 1 year ago

I have tried and the compilation is normal. You may need to use his new installer Message ID: @.***>

Where can I get the new installer and how do I use it? How do I compile it to make it work properly?

jzy-chitong56 commented 1 year ago

https://github.com/SMUnlimited/AMAI/releases/tag/3.2.2.installer