Cobra skirmish AI

Did you create a mod, map, music, or a tool? Present them here and earn feedback!
Note: addon requests do not belong here.
Note, everything uploaded to this forum, MUST have a license!
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Cobra skirmish AI

Post by Cyp »

gamesforfun wrote:can the original owner of this mod please fix it as it contains a virus
Are you sure? Both .wz files are zip files containing only .js and .json files, and it therefore seems unlikely to me that they can contain viruses.
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: Cobra skirmish AI

Post by Berserk Cyborg »

gamesforfun wrote:can the original owner of this mod please fix it as it contains a virus
Most definitely there are none. I notice that sometimes other addons can make Windows Defender freak out over nothing (on Windows 10 anyway).
User avatar
Lord_Kane
Trained
Trained
Posts: 104
Joined: 24 Nov 2016, 21:51

Re: Cobra skirmish AI

Post by Lord_Kane »

gamesforfun wrote:can the original owner of this mod please fix it as it contains a virus
https://www.virustotal.com/en/file/4ed3 ... 495599476/

Virustotal reports it as clean, so whatever you are using is way to paranoid.
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: Cobra skirmish AI

Post by Berserk Cyborg »

Releasing Cobra v1.13. Fixes some undesirable behavior and makes improvements in build, production, and research.

-Reduce performance impact on larger maps. The code that the artillery group used to find something would get worse on larger maps.
-Better at keeping its power levels balanced.
-Gets to thermal armor sooner.
-Get rearming pads before trying to get other VTOL related tech.
-Builds different types of sensors in base. Sensor related research takes a higher priority now.
-It can now produces the rapid fire versions of weapons (such as the Hellstorm howitzer) in addition to the rest of the weapon line. Also grenadier cyborgs stop being produced once it gets Pepperpot mortar.
-Added chat command "oil level" to tell players if it is a low, medium, or high oil map.
-Personalities no longer forced to use hurricane/whirlwind as Anti-air defense.
Cobra.wz
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: Cobra skirmish AI

Post by Berserk Cyborg »

Releasing a new version for testing. Changes from the previous versions include performance impact reduction and fixing bugs with tactics. I think the next thing I will focus on improving is the build decisions and allowing personalities that prefer cyborgs/VTOLs instead of just focusing on tanks early on.
Cobra.wz
813gan
New user
Posts: 1
Joined: 17 Jul 2017, 22:43

Re: Cobra skirmish AI

Post by 813gan »

gamesforfun wrote:can the original owner of this mod please fix it as it contains a virus
I just downloaded both master brunch from github repo and next version linked in this thread (git repo SHA256:bfa6f7b86e93e6f949585a0bc56a5633c2fe330629a30a05b78e3cf17f27bb90)
(version 1.11 SHA256:1152c555eb0cedb7a958b760808a485656bfb2c03241fa3300864f09f79c9530)and updated it to virustotal, it looks like you are wrong, these files are clear.
User avatar
JimmyJack
Trained
Trained
Posts: 118
Joined: 06 May 2017, 05:50

Re: Cobra skirmish AI

Post by JimmyJack »

Downloaded it. Played it. It is tuff. A little slow to get started. I have seen the other AIs truck rush it. I also seen it recover from a truck rush but only at the higher settings. I like this AI thou it fights like I do.

Good work BC. What ever you are doing ... keep it up.
Transmission ends ...
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: Cobra skirmish AI

Post by Berserk Cyborg »

Today I would like to present Cobra AI version 1.28. The main improvements lately are to early game survival and localized regrouping of units that are attacked, when outnumbered, which greatly allows it to stop being easily rushed all the time. My tests show it can survive and beat SemperFi-js much more often, 1v1 and teamed, so there is that I guess.

Tested on master and should work with 3.3 beta1 also.

Edit: Added version 1.30. Get it from the release page here.
nick87720z
Trained
Trained
Posts: 130
Joined: 25 Feb 2014, 16:37

Re: Cobra skirmish AI

Post by nick87720z »

Tried master version against bonecrusher at fortscav.

There are some problems with structures layout among others:
Image

1. Chess like defense struct layout. The shift seems to happen at some point due to bad alignment with terrain. Though units usually try to move between diagonally placed structs, it happens so slow, that they are practically unpassable.

2. Bad idea to ignore building defenses near oil at high-oil maps. Oils are as important as base itself. It would better to depend not on map type, but on structure number limit, so that number of dericks at least distance from base would be treated as essential for defense. At least from truck rush.

3. Bad usage of repair facilities. It looks as if cobra did even this by micromanaging, without retreat at damage option. Even if it is necessary in some cases (to prevent retreating units passing through dangerous places), it still could give command to retreat for repair at some distance from base.

3.1. Noticed, that if two or more facilities are enough close, retreating unit places itself so, that more facilities can reach it. Besides first coming to mind 2x2 facilities grid, I eventually got even better configuration, placing all 5 facilities in pentagram formation, which has point, where all 5 facilities can reach. There is monospaced-text demo for layout (without common space):

Code: Select all

--R--
R---R
-----
-R-R-
Yet, when trying cobra_v1, it placed one of centers in front of base, while others - at side, similar to this screenshots. Using repair cluster, there still could be some point, where units could be all placed by micromanagent without healing command. Though... should not simple click to repair center have same effect as return-for-repair command, with automatic distribution between facilities? If so, than if movement to facility is done by some virtual click to repair center, than such command could treat same effect. From another side, placing repair centers at bigger distance allowes more units to collect around them with less mess for those units, which need to get out of mess, to reach rally point, thus freeing space for more waiting units.

By the way, specially for micromanagement way, there could be temporary retreat point, not far from current enemy front, each with group of repair units, set to hold position. Also, if AI plans to use aviation, clusters of single facilities, surrounded each by 12 vtol pads (3 per side) could be used. Of course, when AI desides to use them for ground units (e.g. if enemy front stably develops backward), any vtols should be removed from its pads to avoid mess (if it uses so much micro, it could also direct vtols to specific pads, even not allowing them to attack chaotically one by one, like human players would do).

4. Do any AIs manage rally points for factories and repair centers? It is problem, since units in middle of base usually stay on the way of trucs during maintainance. Imho, placing rally point should be as simple as building defense. Also it seems strance, that just-produced combat units go to combat immediately as if had proper rally point, but units from repair don't. These points could be placed somewhere outside base.

5. If some unit path management could be possible, this would be used in items 4, 3, 1 and some more. In short, these should include trucks maintainance path, path for constructed units to rally points and path for retreating units. Also it could affect base build order. According to it, generators and labs should be in deepest inside of base. Tank factories should be after them, so that tanks have easy access to upgrade them. Cyborg factories are ok to be in front of them, since they don't have upgrades. Vtol factories could be deeper, since vtols don't need to move by ground. Repair centers need to be positioned so, that mess of units, waiting for repair, doesn't stay on way of produced units.

6. If conception of player/team front is doable, it could be used to place rally points. I noticed, that at this map all BC units are directing to middle oils at some side from very base entrance, only changint couse when detecting enemy units (meaning, that unit detects, not AI player).

7. Remembering nullbot movement style for combat group, it seems to have advantage, moving forth and bath, since it allowes quick regroup, since damaged units more easily retreat when surrounding units in movement. Could be not as advanced as side movement, but in some places it is only possible movement style (like in any narrow passages. One drawback though is that nullbot set back movement point too far, so that approaching units also turned without stable closing to combat point.

7.1. Cobra tries to regroup units when they are damaget, but seems doing it not so effectively. Combined with 7(.0), units, included to potential group, including those, still in approach, could be frequently moved slightly behind of current contact point so, that forward unit retreat, but those behind approach, each new movement slightly more behind. This way retreating units would give good fight back, eventually going to reliable offense.

7.2. I remember, there was question about nullbot ability to measure enemy treat size, so that required size of battle group could adapt. Is not it possible to detect e.g. enemy units in sensor range of each unit? If so, this info could be used to measure this. More exactly, it should ration between units under fire to units, reaching enemy with fire, but for better planning, it could be units in sensor range.

8. Some idea, how sensors could be used, possible for insane skill level. When passing through unsecured zone, they could move in zigzag way (hovers only), so that enemy arty would have hard time with it. There could be pack of replacement sensors in some safety, and sensors would be used one by one, probably made as tough as possible (for hover of course). Btw, some bodies could be ok to be with trucks/half-trucks, especially nexus bodies (middle nexus body should be enough manueverable with trucks due to higher rotation speed). For implementation, there could be some center line, with direction changing each time unit crosses it.
Those, who sacrifice culture for bit of freedom don't diserve any.
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: Cobra skirmish AI

Post by Berserk Cyborg »

nick87720z wrote: 16 Nov 2019, 22:06 1. Chess like defense struct layout. The shift seems to happen at some point due to bad alignment with terrain. Though units usually try to move between diagonally placed structs, it happens so slow, that they are practically unpassable.
If Cobra has no base structures to build anymore then it starts doing a turtle AI like behavior of surrounding it's base with defenses, provided it has enough resources allocated to do so. This is really only going to happen on maps with extreme oil (maybe > 30 per player, or if the match is really long) but I'm not sure if it's good to keep this behavior or not.
nick87720z wrote: 16 Nov 2019, 22:06 2. Bad idea to ignore building defenses near oil at high-oil maps. Oils are as important as base itself. It would better to depend not on map type, but on structure number limit, so that number of dericks at least distance from base would be treated as essential for defense. At least from truck rush.
Cobra doesn't ignore building defenses near oil on high oil maps. It's just at a lower priority compared to low oil. In AI vs. AI it doesn't make a difference (on the maps I tested). Against a seasoned player, probably.
nick87720z wrote: 16 Nov 2019, 22:06 3. Bad usage of repair facilities. It looks as if cobra did even this by micromanaging, without retreat at damage option. Even if it is necessary in some cases (to prevent retreating units passing through dangerous places), it still could give command to retreat for repair at some distance from base.

3.1. Noticed, that if two or more facilities are enough close, retreating unit places itself so, that more facilities can reach it. Besides first coming to mind 2x2 facilities grid, I eventually got even better configuration, placing all 5 facilities in pentagram formation, which has point, where all 5 facilities can reach. There is monospaced-text demo for layout (without common space):

Code: Select all

--R--
R---R
-----
-R-R-
Yet, when trying cobra_v1, it placed one of centers in front of base, while others - at side, similar to this screenshots. Using repair cluster, there still could be some point, where units could be all placed by micromanagent without healing command. Though... should not simple click to repair center have same effect as return-for-repair command, with automatic distribution between facilities? If so, than if movement to facility is done by some virtual click to repair center, than such command could treat same effect. From another side, placing repair centers at bigger distance allowes more units to collect around them with less mess for those units, which need to get out of mess, to reach rally point, thus freeing space for more waiting units.

By the way, specially for micromanagement way, there could be temporary retreat point, not far from current enemy front, each with group of repair units, set to hold position. Also, if AI plans to use aviation, clusters of single facilities, surrounded each by 12 vtol pads (3 per side) could be used. Of course, when AI desides to use them for ground units (e.g. if enemy front stably develops backward), any vtols should be removed from its pads to avoid mess (if it uses so much micro, it could also direct vtols to specific pads, even not allowing them to attack chaotically one by one, like human players would do).
Return to repair seems to just tell units to go to the nearest repair and doesn't check for surrounding units among the others, so things can get very congested easily. Doesn't help that I made Cobra units repair at a medium-high level, but it works pretty well on traditional low/medium oil maps.

Maybe I could have a special case where I use pickStructureLocation() near the first repair facility. But there will be edge cases where that will fail (if near edge of the map, for example). I'll do some experiments with placing repair facilities at the outer edges of the base.

I experimented with putting VTOL pads around factories and the HQ. While it looks cool, it leads to more congestion in base and the current behavior is better, IMO.
nick87720z wrote: 16 Nov 2019, 22:06 4. Do any AIs manage rally points for factories and repair centers? It is problem, since units in middle of base usually stay on the way of trucs during maintainance. Imho, placing rally point should be as simple as building defense. Also it seems strance, that just-produced combat units go to combat immediately as if had proper rally point, but units from repair don't. These points could be placed somewhere outside base.
No, I don't think any AI can manage the rally points. It would be great if they could. But the scriping API has nothing for this.
nick87720z wrote: 16 Nov 2019, 22:06 5. If some unit path management could be possible, this would be used in items 4, 3, 1 and some more. In short, these should include trucks maintainance path, path for constructed units to rally points and path for retreating units. Also it could affect base build order. According to it, generators and labs should be in deepest inside of base. Tank factories should be after them, so that tanks have easy access to upgrade them. Cyborg factories are ok to be in front of them, since they don't have upgrades. Vtol factories could be deeper, since vtols don't need to move by ground. Repair centers need to be positioned so, that mess of units, waiting for repair, doesn't stay on way of produced units.
I don't believe base ordering like that is necessary for a bot. If a decent amount of units can get into a bot base then the bot will be dead. Same for a human player. The one thing that should happen for any bot is ensuring repair facilities stay at the outer confines of the base.
nick87720z wrote: 16 Nov 2019, 22:06 7.1. Cobra tries to regroup units when they are damaget, but seems doing it not so effectively. Combined with 7(.0), units, included to potential group, including those, still in approach, could be frequently moved slightly behind of current contact point so, that forward unit retreat, but those behind approach, each new movement slightly more behind. This way retreating units would give good fight back, eventually going to reliable offense.

7.2. I remember, there was question about nullbot ability to measure enemy treat size, so that required size of battle group could adapt. Is not it possible to detect e.g. enemy units in sensor range of each unit? If so, this info could be used to measure this. More exactly, it should ration between units under fire to units, reaching enemy with fire, but for better planning, it could be units in sensor range.
This is an interesting idea. Would certainly increase the longevity of skirmishes and not concede some ground due to repairing units. I think I can emulate this.

Yes, it's possible to see enemy units around a unit. I do this (albeit with cheat vision) up to 7 tiles away every time a Cobra unit is attacked to determine if it should retreat or not in eventAttacked.
nick87720z
Trained
Trained
Posts: 130
Joined: 25 Feb 2014, 16:37

Re: Cobra skirmish AI

Post by nick87720z »

There is problem, when units count reaches limit, it can't produce more updated units, and existing outdated are forced to givup. The more they resist to destruction by frequent retreating, farther disadvantage comes. At high-oil with high-power setting there may be so much energy (probably enough to keep all 15 trucks busy along with labs and factories), that recycling units is meaningless (of course, if experience is important). In this case forward group (directly in confrontation) could just stop sink units by retreating, but as always revolve them as much as possible - not always by moving damaged unit back, but also by moving all group forward, execepting one unit, so that it stays behind. Of course, at lower setting (it possible to estimate mediate power reserve growth/loss instead of game settings) units are better to be recycled.

When using aviation, it builds not enough pads, so that sometimes too much units seat useless. It would be not so critical if vtols had light bodies - I understood, why AI (and players too) avoid doing heavy vtols, because rearming speed is backward-proportional to body weight. With all rearming upgrades bug vtol recharges in several seconds, while heavy vtols take several times more (this is also reason why rearming in EB/contingency is so slow - due to immense body weights, set by that mod). Thus, when it uses heavy bodies (since must have for MG/Cannon/Laser vtols by same reason as for tanks), it should always care about extra pads. And pads should not be placed among forward defenses - better mix them with structures, that don't need upgrade (e.g. oil derics or even labs/generators, once already upgraded). Also noticed, that medium collective body has same weight than heavy NP's (so, NP one has same stats, but better engine => can carry heavier weapons).

If vtol rearmed more quickly than repairs, it could consider moving to unused repair center if any. No need to land, just hang for some time, e.g. by chaining several points around facility (at least two at opposing sides) and last at side, where all these vtols are collected (I noticed, that Alt+Click move command can't be chained, as it is performed immediately, dropping all current chain).

Trucks, leaving unfinished structure when interrupted by fire, keeps creating new, tending to leave them unfinished. At above screenshot it already left two, still trying to create more (as far as I remember, this group had nearly 6 or 4 trucks). If it retries, it should retry so, that to avoid enemy, and choose place for new structures in safer point (farther from enemy), avoiding so called "compromised" zone. And always consider to finish unfinished.

And example of how it could better handle above situation. If it desides to seal base with unpassable line and completely go turtling (lets forget enemy truck, on background), it could consider sacrifice units in same way as described in context of avoiding game units limit. This would give more time to build more hardened defense. For begining it would restore trucks number with e.g. hover bugs, then replace them with heavier and tracked trucks (I remember, TurtleAI is initially supposed to use heavier tracked units, although actually it does only trucks and vtols). But still not dropping to produce battle units for better defense. For begining defenses should form line, not chess. Below are possible transformations:

Code: Select all

1.                2.                   3.
...-----------... -> ...-----------... -> ...-----------...
...D-D-D-D-D-D... -> ...D-D-D-D-D-D... -> ...D-D-D-D-D-D...
...-----------... -> ...-----------... -> ...-----------...
...D-D-D-D-D-D... -> ...DDDDDDDDDDD... -> ...DDDDDDDDDDD...
...-----------... -> ...-----------... -> ...D---D-D---D...
...D-D-D-D-D-D... -> ...D-D-D-D-D-D... -> ...D-R-D-D-R-D...
Also could be 3/2 or 5/3 line variant, where both lines are available for maintainance, but with second line with gaps. It should have wall hardpoints in similar to chess layout, with bunkers filling forward gaps. Two maintainable layouts come to mind:

Code: Select all

...dDdDdDd... | ...dDddDddDd...
...D-D-D-D... | ...D-DD-DD-D...
As seen, second is hardest to maintain, needing more frequent truck relocation (15 turtling trucks are enough to cover 45 tile long section without background assistance). For more localized cases could be e.g. 10 on positions and 5 for point assistance). Btw, support also could be done by heavy engineers in patrol mode, to heal trucks in addition to turrets (5 turrets are unable to cover all trucks even in first case - trucks stay inside of second line, and facilities can't be closer than 1 tile from this line, so only for assistance itself).

Also it could opt to two-level line, consisting of wall hardpoints and bunkers. I'm unsure though, what is better between bunker and gunpoint. Bunkers are harder, but vulnerable to flame. Gunpoints are not, but they are all weak, and die quickly without flame. Twin-mg is available only at wall, while twin-AC (if memory is correct), only as bunker. If trying to convert one-liner to two-line while under fire, it could try to build new lines behind existing, but each such rebuild means giving up 1 or 2 tiles, unless it upgrades it to fracture-named layout, so it should maintain it as long as possible, using heavy turtling trucks. If possible, build new repair centers right behind wall, placing along wall but closer to assault point, probably 2 tiles behind wall (not 1, as 2 is enough).

And finally, when it comes to point of deciding to go turtling (when it looses), initial MG towers are too outdated. Even with MG it should opt to MG hardpoints (and research hardcrete HP, as any turtler). In above case already built MG tower grid could be cover, while more serious line is built. Of course, necesary structures already should be researched (crete HP could be later, yet mentioning that by some reason they get crete upgrades instead of base structures, though it is just steel... just thought, what if it gets composite armor upgrades, even with thermo alloys... same about high-tech T3 gun points :).

Btw, I got more ideas about possible repair center cluster. The maximum distance between two centers to reach two units is 3 tiles. For omni-directional quad variant it would 2 tiles (against 1 from above post). And with 3 tiles it could be two-directional quad variant with 3x1 distances. With fifth in the middle it forms ideal two-directional variant, where all 5 have intercection point as well. Somewhat more compact and practical, than above pentagram layout (given user can pick proper orientation for it). Of course, in case if high load - linear array should be preferred, given there is enough space for it (still better to place it aside from ways from production lines).

Somewhat close to path management. I noticed, that placing repair centers at side of base is one way to avoid mess between retreating and exiting, but seems to be not enough in some cases. Though don't know, is it possible without terrain analyzis (discussed in other threads, in context of unoptimal defense builds), another way could be to reserve space for them deep in base (ideally - behind factories or at one line with them).

I finally thought about something, more related to terrain analyzis. If unit can detect two walls are unpassable terrain edges at some distance from it, it could be used to detect choke points - both to prevent obstructing it e.g. with base structures and repair/rearm facilities, or to fill it with defenses at first (in case of turtling it could allocate complete defense line, with free space for access and support, twice or more times longer than this gap).

Just wonder, how much JS bot can do without making game unplayable :)
Those, who sacrifice culture for bit of freedom don't diserve any.
nick87720z
Trained
Trained
Posts: 130
Joined: 25 Feb 2014, 16:37

Re: Cobra skirmish AI

Post by nick87720z »

Just tried same version (3 days old) at startup. Mods besides AI: EB, ultimate-scavs for 3.3.0, ArtRev.
Cobra at hard, save file is attached. I'm trying AI against scavangers on its own - to do so, I just kill own trucks (watching all in debug mode, with enabled global view by Ctrl+G) - too bad can't do it to enemy, to try on its own :)

So, problem is that cobra trucks at base do nothing, despite there are 3 more dericks built. Looked to later commits names - not sure if they affect this.
Attachments
test-cobra-uscav.zip
(113.12 KiB) Downloaded 152 times
Those, who sacrifice culture for bit of freedom don't diserve any.
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: Cobra skirmish AI

Post by Berserk Cyborg »

nick87720z wrote: 18 Nov 2019, 20:17 So, problem is that cobra trucks at base do nothing, despite there are 3 more dericks built. Looked to later commits names - not sure if they affect this.
I know about this one. But it's not a problem with the bot. It's a failure with pickStructureLocation(). It can't find anywhere to place the HQ on Startup Position 0 so it forever gets struck trying to find a location to put the HQ. I have been suspicious that pickStructureLocation() can also fail around water tiles too.
nick87720z
Trained
Trained
Posts: 130
Joined: 25 Feb 2014, 16:37

Re: Cobra skirmish AI

Post by nick87720z »

Hm, could it be same case at Butterfly pos1? When I tried two cobra agains each over or cobra vs crusher, placing self at 2 (still had to kill trucks, which were not removed by spectator mod). Thought it is due to mod, but it seems stable - cobra at this position stops to develop base after 2 factories and lab (don't remember if it built generator). Bonecrusher has no such problem. Do they use different methods?
Those, who sacrifice culture for bit of freedom don't diserve any.
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: Cobra skirmish AI

Post by Berserk Cyborg »

^ I made a workaround where I randomly offset the locations passed to pickStructureLocation() up to three tiles. This made it possible for Cobra to build its base on Startup position 0 and all Butterfly map positions. It shouldn't negatively affect anything and hasn't from my tests so far.

Another factor to consider is what base structures were already built which will influence what location pickStructureLocation() will choose (since I build around startPosition[me] when building in base).

Edit:
cobra.wz
version 1.36
(38.43 KiB) Downloaded 203 times
Post Reply