AI-Uveso (v114) - AI mod for FAForever
-
I think I might have a fix for the FAF code in NIX2 compressed code archive.
The error was
...ver\gamedata\lua.nx2\lua\sim\Unit.lua(3067): attempt to call method `bp.BuildCostEnergy' (a nil value)
The original code and my fix.
ORIGINAL: ----------------------- local scale = math.min(4, math.max(1, (bp.BuildCostEnergy / bp.BuildTime or 1) / 50)) FIX: ----------------------- local scale = 4 if bp.BuildCostEnergy and bp.BuildTime then scale = math.min(4, math.max(1, (bp.BuildCostEnergy / bp.BuildTime or 1) / 50)) end
-
I will rebuild the whole commander function, the last tournament showed how weak it is.
(I am a turtle player and never see the AI ACU fighting)Yes there is a function to check blocking terrain for weapon fire:
CheckBlockingTerrain()
https://github.com/Uveso/AI-Uveso/blob/master/hook/lua/platoon.lua#L3283
(It's not implemented to the commander function yet)
attempt to call method `bp.BuildCostEnergy' (a nil value)
This means, there is no entry inside the blueprint of this unit to calculate the
CreateEnhancementEffects
Just changing the code inside unit.lua is not a good solution.
The function itself is ok, but the blueprint is missing the BuildCostEnergy for an enhancement.So the blueprint must be fixed, not the function that reads the blueprint value.
-
Thanks for the reply
@Uveso said in AI-Uveso (v91) - AI mod for FAForever:
Tactical missile launchers are defense buildings for an AI.
It will attack land experimental units with it. Also T3 mobile arties that are close to the base.I am very much doubting how effective this is, it is easy to dodge (I used to do it all the time, I've been liking non-experimental tactics lately). For the very considerable amount of resources it consumes that could be spent elsewhere. Long range defence would be better as T2 static arty.
A trick I used to use to make sorian AI harder back in the day (it loved TML too) was to prevent the building of it. Made the AI noticeably stronger!
Nuke silos are always builded (so the player can see the threat) but are not always loading missiles.
(they are idle/paused most of the time)This is cool!
But the other point was that the AI could occasionally (especially if adaptive or experimental) mix it up and build a T3 arty instead.
-
Well you should have in mind my AI is meant to be played with several mods.
There are slow and hevy experimentals with more than 400,000 healthpoints.
They can't dodge and can be easily killed with tactical missiles.
Also T3 static artillery is mostly useless when you have experimental shields.But i will increase the buildratio for artillery. They should be as much artillery than nuke silos at least.
Btw, why don't i see you on our AI-Development discord ?
-
@Uveso
Hi Uveso,Yes, fixing whatever unit would be great if the error message mentioned what unit caused the error.
-
@Uveso
Im not sure what version of LUA is being run by FAF, but there is a web page with reference for various versions of LUA.
5.4 version https://www.lua.org/manual/5.4/manual.html#3.4.1I wonder if someone setup a code to check the wall-clock time, and after xx minutes to force a LUA garbage cleanup, if some of the memory problems would go away.
Although from the format of the parameters, it seems like it might only be callable from C language.There appears to be a LUA function for also calling "C style" functions, perhaps combine them if it truly is C function.
int lua_gc (lua_State *L, int what, ...);
Controls the garbage collector.
This function performs several tasks, according to the value of the parameter what. For options that need extra arguments, they are listed after the option.
- LUA_GCCOLLECT: Performs a full garbage-collection cycle.
- LUA_GCSTOP: Stops the garbage collector.
- LUA_GCRESTART: Restarts the garbage collector.
- LUA_GCCOUNT: Returns the current amount of memory (in Kbytes) in use by Lua.
- LUA_GCCOUNTB: Returns the remainder of dividing the current amount of bytes of memory in use by Lua by 1024.
- LUA_GCSTEP (int stepsize): Performs an incremental step of garbage collection, corresponding to the allocation of stepsize Kbytes.
- LUA_GCISRUNNING: Returns a boolean that tells whether the collector is running (i.e., not stopped).
- LUA_GCINC (int pause, int stepmul, stepsize): Changes the collector to incremental mode with the given parameters (see ยง2.5.1). Returns the previous mode (LUA_GCGEN or LUA_GCINC).
- LUA_GCGEN (int minormul, int majormul): Changes the collector to generational mode with the given parameters (see ยง2.5.2). Returns the previous mode (LUA_GCGEN or LUA_GCINC).
-
The version of LUA used by SCFA is a modified 5.0 - which has no I/O functions and no access to the GC controls.
-
About ACU again - any code that can detect whether other AI players also have AIX Omni settings? When AI is playing against other AIX with Omni, don't upgrade ACU with Stealth.
-
@Uveso said in AI-Uveso (v91) - AI mod for FAForever:
Well you should have in mind my AI is meant to be played with several mods.
There are slow and hevy experimentals with more than 400,000 healthpoints.
They can't dodge and can be easily killed with tactical missiles.
Also T3 static artillery is mostly useless when you have experimental shields.Good to know the reasons, I play mostly vanilla supcom compared to that stuff, I am loving SCTABalance and occasionally we play with blackops, mostly for the upgradeable hydro
Btw, why don't i see you on our AI-Development discord ?
... I have no excuse!
-
@Gladry said in AI-Uveso (v91) - AI mod for FAForever:
@Uveso
Hi Uveso,Yes, fixing whatever unit would be great if the error message mentioned what unit caused the error.
Next AI version has a new error message like:
WARNING: Unit [uel0001] has no BuildCostEnergy in enhancement [HeavyAntiMatterCannon] - "Unknown name" - "<LOC uel0001_desc>Armored Command Unit"
So you can see what unit is causing the error.
if you whant to test it on your own use this:
if not bp.BuildCostEnergy then WARN('Unit ['..self.UnitId..'] has no BuildCostEnergy in enhancement ['..enhancement..'] - '..repr( self:GetBlueprint().General.UnitName or "Unknown name" )..' - '..repr( LOC(self:GetBlueprint().Description or "Unknown description" ))..' ') end
-
Hi Uveso,
Question - better here or in main mods thread? You decide.
I found a mod I liked but with a few bugs.
Your AI automatically uses this mod, if installed.It is "AutoReclaim-dwm" - A series of auto-reclaiming auto-assisting engineering turrets.
I've made most of the fixes, one problem remains.
WIth every faction, except Cybran, if the unit is upgrading to a higher level (1->2 or 2->3) - choosing [stop] causes the unit to (apparently) self destruct. Cybran begins update, continues update, stops update on demand and reverts back to original before upgrade was attempted.Self-destruct because before upgrading, or during upgrading - choosing ctrl-period shows that unit and all other engineers.
However after "self destruct" - ctrl-. shows only other engineers.I have studied the LUA code and .BP definition for the DWM version of Cybran tower. I have used programmer text edtor DIFF tool to compare that to the other faction's towers.
I have edited the other towers to make them as close as possibly the same as Cybran.
Of course Cybran LUA class is CConstructionStructureUnit and UEF is TConstructionUnit and so on. Those difference are expected and left alone.These do NOT appear to be merge units, so I am unsure if existing class member methods for original units are still called by FAF. By which I mean "original game had cybran engineering unit, so any over-write unit with same unit blueprint name does or does not get benefit of code associated with that unit name.
-
Update 30.Mar.2021(v92)
- New: Added option for AIx Overwhelm for variable start time and cheat increase (thanks to bergzand)
- Fix: AI brain will now be deleted after a defeat in a forked thread to prevent errors
- Fix: PlatoonFormManager is now able to delay equal formplatoons same like buildplatoons
- Debug: temporary added gamefix for experimental transporters
- Debug: added log output for missing buildcost on enhancements
- Debug: temporary removed function TransferUnfinishedUnitsAfterDeath for testing
-
@Gladry:
i have installed the mod and can confirm the destruction.
i will do a check later, maybe i find something. -
Was playing on some maps, with initial launch area space restrictions, and your AI was creating Crazy numbers of T1 anti-air mobile units. These units were blocking all of your spaces between buildings and paths out of your initial launch area.
Also even after 20 minutes it was still keeping dozens perhaps 50+ T1 anti-air mobile units. Still blocking engineer and other unit movements in your base.
For base defense, does your AI evaluate static A defenses vs static B defenses (Ie different mods) vs mobile units?
Example:
build time + energy/mass cost and DPS + range of xx mobile tanks vs
BT +E/M and DPS + range of yy turrets?Direct fire vs ballistic units (that can fire over blocking terrain)?
-
Hey @Uveso
It seems I am having trouble using with Nomads. Is this a known incompatibility? Upon ACU drop-in (when playing as Nomads), the mass and energy seem to go nuts. Along with this, the commander starts out with the t3 build suite and it does not produce a crash or any error. This only occurs when Uveso is active, even if there are no AI's in the match. This does not happen when playing as any other faction. It is the only mod active. Nomads works fine when no mods are active. Tried this on multiplayer with a friend and there is an immediate desync. He also has this issue in solo games as well. Any help would be appreciated since I love both the uveso AI and nomads for high cheat level challenges.
Thanks! If you need logs, let me know.
-
@Gladry
Do you mean the no rush option ?
My AI has special builders for the no Rush Option, maybe i missconfigured the AA builders.
I will check this.@ctrlaltdelete
AI version 92 was more or less for debugging, and i did not check the functionality with Nomads.
I will test nomads for the next AI version and fix it.
(since i also can patch the Nomads mod it will run in every case even if the problem is inside Nomads)Thanks for reporting !!!
-
@Uveso said in AI-Uveso (v92) - AI mod for FAForever:
@Gladry
Do you mean the no rush option ?
My AI has special builders for the no Rush Option, maybe i missconfigured the AA builders.
I will check this.Question #1: T1 AA mobile units
- In this game no-rush was not turned on - I assume the answer is about this, in any case no-rush was not on for either question.
- T1 AA mobile were still being built at 18 minutes in, I know as I allied with an Ai-Uveso player and reclaimed (killed) 20+ T1 AAs to remove them - more were built
Question #2: Base planning
- If a ground turret costs as much to build as 4 T1 tanks, and 4 tanks combined do 10% more damage build faster in 80% of the time - it makes sense to build the tanks instead.
- However if someone added a mod which changed the range or DPS, build time, or build cost of the fixed turret, turret would probably be better - especially if range is significantly farther.
- Code might check for this. AI designer might presume tanks or mobile light artillery are go-to solutions, or make comparison code
Question #3: DPS calculation
- In your function CalculatedDPS(weapon)
- your comment states "--Game logic rounds the timings to the nearest tick -- math.max(0.1, 1 / (weapon.RateOfFire or 1)) for unrounded values"
- You use the calculation of actual rate of fire which I have seen mentioned elsewhere, but in no cases have I seen, when mentioned, round up or round down. I don't know for certain (you probably do) if it rounds up or rounds down.
- Will effective rate of 1/rate = 1.66666 end up being 1.7 or 1.6. Rounding up by 0.5, as your code does, will make it 1.7 which of course is slower . 17 game ticks being more than 16 ticks.
- Do you or others know where the FAF lua code that actually decides? I can see if the game code puts the 1/rate value into a variable, and every tick subtracts 0.10 from the value until it is <= 0, that would effectively be rounding up.
-
@ctrlaltdelete
please update Nomads, a patch for the error was already released in Nomads 6 days ago:
https://github.com/FAForever/nomads/pull/626@Gladry
T1 AA mobile units:
I will reduce the amount of mobile AA in the next update.Base planning:
My AI is meant to be played with unit mods like Total Mayhem. Thats why i have builder for pointdefenses.
Sadly you can't determine the cost of a unit before you build it.
The AI will assign a buildtask to an engineer and only the engineer will know how much the unit costs.DPS calculation:
The game does not have any DPS calculation in LUA, it's all calculated hidden inside the c-engine.
we only try to mimic the c-eninge with LUA functions. (it is not always accurate) -
if bp.Economy then if bp.Economy.BuildCostEnergy and bp.Economy.BuildCostMass ... end if bp.Economy.BuildTime then bp.Economy.BuildTime = end
-
I am sorry i don't know what you want to tell me with this code snippet
Its not a part of the code we talked about, enhancements don't have a Economy sub table.
Also you don't need to ask for if bp.Economy then when you need to know if bp.Economy.BuildCostEnergy exists.
Just call directly if bp.Economy.BuildCostEnergy. it will return false if bp.Economy is missing.