NullBot research choices #4688
Comments
darkling uploaded file alternative function |
NoQ commented At a glance, this works correctly, even though i agree that the code looks weird. I see that |
darkling commented Interestingly it didn't really worry me that the function wasn't being called without all the arguments being called since the default was specified. It's just that as far as I can see the function weaponPathIsAvailable is only called in that one place, which was why I wasn't sure if it was doing what it was supposed to be doing. Otherwise the default is probably fine at least computationally (calling findResearch on a research item that is a long way from being researched is apparently not very efficient). I can see two reasons for testing whether a path is available, firstly to make sure it doesn't try researching lasers right from the start (24 minutes to the first weapon from teh weapons guide) and then to make sure it doesn't get stuck trying to research a completed path. Although if a path is completed it's because it thinks it's the best one so will most likely be picking weapons from it anyway. |
Berserk Cyborg changed blocking which not transferred by tractive |
Berserk Cyborg changed blockedby which not transferred by tractive |
Berserk Cyborg commented How about this?
|
darkling commented For my own mod of NullBot I implemented a less elegant version of that. One thing I noticed was that calling findResearch added a fraction of a second to the execution time when there's a lot of items that need researching (maxR > 100). It might not be noticeable on a modern system but if you're running a lot of AIs on a map then it could stutter occasionally. In the end I used componentAvailable (or isStructureAvailable) for the last items because they were faster. So it counts how much research is needed for the first item in the path and whether the last item is available (true/false). However for NullBot, I'm not so sure that it's necessary. Nullbot makes its weapon and research choices based on the ratio of observed enemy troop types. So the weaponPath it's choosing to research (except for a small random element) will be the weapon types that it will be deploying. So with nullbot I don't know if it gains anything from researching additional paths (if it's not going to deploy them). It might be enough to just include the test for minR and remove the test for maxR (or change maxR to a true/false test for availability of the last item). One alternative change that's related to this and might be useful to implement is in the weaponStatsToResList function. This function pulls together the list of research items that are then passed to the lab.
I just added the line
to it. extras is a defined field in weaponStats and most of teh weapon paths have extras listed but I don't think they're used anywhere in Nullbot currently. so including them here should help nullbot get the most out of its chosen weaponpath. |
Berserk Cyborg commented Hmm, yeah I guess Nullbot misses a few research items then if it does not use the extras. Unfortunately, my version of weaponPathIsAvailable does not work too well on T1 advanced bases because Nullbot tries to research the incendiary mortar while using completely different weapons. :/ |
type_patch (an actual patch, not a request for one)
| by darklingI was digging into nullbot code and noticed some code which I don't think is behaving as intended. There's a function whose roll is to identify available research for different objectTypes (tank, template, vtol of defence) however objectType isn't passed to it so the default option is always called which is that the research is available.
Line numbers are for nullbot 3.06 on master, but the issue was noticed using an older version
Line 75 of research.js calls several functions:
var list = weaponStatsToResList(chooseAvailableWeaponPathByRoleRatings(personality.weaponPaths, chooseWeaponRole()), objType);
the issue crops us with the call to chooseAvailableWeaponPathByRoleRatings (located at line 134 in stats.js). The actual function asks for 4 (paths, rating, objectType, defrole) values whereas 2 are given (paths, rating).
At line 137 of stats.js the chooseAvailableWeaponPathByRoleRatings function calls the function weaponPathIsAvailable which asks for three variables (path, objectType, defrole).
weaponPathIsAvailable uses objectType to pick between research options but since that is not specified it always calls the default option (I think).
Fixing it looks a little bit more involved since just including objectType in the initial function call looks like it will make switching weapon research difficult since the function weaponPathIsAvailable tests using componentAvailable.
I've attached a version of the function that I wrote for my mod of nullbot. objectType is included in the initial call to chooseAvailableWeaponPathByRoleRatings so that it is then passed to weaponPathIsAvailable. It doesn't use defrole so you may need to make some changes if you want to include that variable.
Issue migrated from trac:4688 at 2022-04-16 12:58:28 -0700
The text was updated successfully, but these errors were encountered: