Counterstrike AI!

by:	David Sellick (A>K<A Switeck)
email: Switeck@hotmail.com

"If they ain't coming out of the woodwork, something went wrong."

"And YES, It cheats."


NOTE: This ai uses hacked units which *MUST* be installed on all computers in a multiplayer game in order for the ai to work.
CS ai is the abbreviation for CounterStrike ai.
BAI is the abbreviation for Brave Sir Robin's Bloodthirsty AI.


Special features of this ai: 
1.Fluxors can be built both on land and underwater (and they're still just one unit!)
2.Ai-only bombers (and Seaplanes!) added for greater difficulty on air maps 
3.TA:CC-required ai units are now in a separate ufo so this ai can be used by people w/o TA:CC.

To install:
----------
NOTE: Since the Zip file has a tree structure, it should work JUST
FINE to unzip it directly to the TOTALA directory.

IF THAT DOESN'T WORK:

1.Move the UFO files into the TOTALA directory.
(This directory is typically C:\CAVEDOG\TOTALA)
These files are:
Ai_Air.ufo		Ai-only aircraft
Ai_Cheat.ufo	Ai-only resource units
Ai_TACConly.ufo	use *ONLY* if you have TA:CC - more cheats
Swi_nuke.ufo	Ai-only nuke silos and fake nuke silos
Ai_Super_Fluxor_Cheat.ufo	replace Ai_Cheat.ufo with this if CS ai doesn't seem hard enough!

2.Create an AI directory under the TOTALA directory.
(This directory is typically C:\CAVEDOG\TOTALA\AI)
3.Move the TXT files into the AI directory.

It's installed!

IF you enable Ai_Super_Fluxor_Cheat.ufo, remove Ai_Cheat.ufo as it replaces that file with more powerful units of the same name. Only do this if you find CS ai to be no challenge with Ai_Cheat.ufo...

SPECIAL FILES INCLUDED:
----------------------

SIDEDATA.TDF is actually a BUGFIX to TA, not something special that CounterStrike needs to work (unlike BAI's SIDEDATA.TDF) - except on water maps - because without it, the Arm ai's seaplane platform will quit producing units. The Core ai will never build a seaplane platform in the FIRST place without it! (This is also true for ALL nonhacked ai's.) I took the original SIDEDATA.TDF in the v3.1 patch (rev31.gp3 file) and edited it to include all Cavedog units.

LOS.TDF is also a BUGFIX for TA, it adds the missing sight radii out to the range of a Core Leviathan - so units are no longer so blind. It should work ok even in multiplayer.

Other ai profiles - especially my "Mostly Harmless" ai - can use Counterstrike's special ai units.

To TOTALLY remove this worthless, cheating, unfair ai:
-----------------------------------------------------

1.Delete the ai directory with all the text files in it.
2.Delete the Ai_whatever.UFO files (see above for names)
3.Delete the GAMEDATA directory.
(Deleting GAMEDATA directory removes the TA bugfixes.)

Don't delete all the UFO files if you want the Cavedog's ai to use the special ai units - such as nukes and bombers.
(but probably not AI_Cheat.ufo!)

WHAT THIS AI DOES:
-----------------

This ai uses a simplistic renewable attack force. This is nothing new for ai's in general, BUT many ai's do NOT have proper limits and/or weights on attack units. If this ai's current attack force is 14 flashes, 20 samsons, and 20 merls - and you kill the flashes (which generally are in the front of the attack), the Flashes will get replaced - but only by about as many flashes as were lost. Also if you run the ai's attack force off, some of the merls ussually survive and return later with "friends". Whatever works generally becomes the predominate feature in the ai's attack force (since that is what ussually survives the longest). As the ai builds its base, its attack force grows more complex - starting out with only 1 or 2 level-1 unit types (such as Flashes and Samsons) and slowly diversifying into many different unit types. This way, the ai can get SOME use out of a couple types of specialty units - such as Shooters and Phalanx(i? es? s?) which would get slaughtered if on their own. The ground attack force has a maximum size of around 160 units, which if reached would comprise about a 50/50 mix of level 1 and level 2 units.

The Ai's special nuke silos (in SWI_nukes.ufo) are designed so only the ai can use them. You *CAN* capture them and use them yourself, but you CANNOT normally build them. They do not have to build nuke missiles and instead rely on LONG reload times (of 3 minutes!) to simulate the time it takes to build a nuke missile. Each nuke missile fired from the silos costs 500 metal and 18,000 energy, so it should take the ai a little while to get up enough energy to fire the first nuke missile. Also included in Swi_nuke.ufo are 2 more ai-only units:
the Arm ai Stunner EMP Silo and the Core ai Neutron Silo. The Arm ai Stunner EMP Silo costs less to fire than the ai nuke silos, but is less useful and as a result is built less often by the ai. If the Arm ai Stunner EMP silo gets vetran status (I've seen these with kills!) it can fire faster than a player's antinuke silo can reload! The Core ai Neutron silo uses the same weapon as the Core ai Silencer nuke silo because I couldn't get the badtargetting lines for the Neutron silo to target only mobile arm units -- which is the only units affected by it. Originally, it did have a special weapon that only affected Arm mobile units. But even with semi-reasonable badtargetting lines, the Neutron silo was targetting factories, metal extractors, and the like -- which it had no effect on. I gave it the nuke weapon from the Core ai Silencer nuke silo so it could affect whatever it targetted, and KEPT (I think I kept...) the badtargetting lines so it would prefer to target mobile Arm units. This means it costs FAR more for the Core ai to use the Ai-only Core Neutron silo than for the Arm ai to use the Ai-only EMP "Stunner" silo. (Even the ORIGINAL Neutron weapon was more expensive than the EMP weapon, but this is moreso.) Because the ai's EMP silo's missiles are cheap compaired to the ai nuke missiles, I do not mind as much if it stupidly shoots one at a lone metal extractor occassionally. But wasting nuke missiles or neutron missiles on lone metal extractors wouldn't do!

All the nuke silos provide radar jamming over a 1,000 pixel radius -- this makes up for the lack of any fixed jammer, and costs the ai a tiny -1e/sec to maintain. In the event the ai even temporarily runs low on energy, this jamming field is temporarily disabled.

Strangely missing is an ai-only antinuke silo. This is because nobody could make one that worked -- it's a limitation of the code that defines how antinukes work. Under special conditions, I'd gotten an ai's antinuke to shoot down incoming enemy nukes in multiplayer games and in missions -- but these conditions are exacting enough to make them unuseable except in missions. In each case I "give" the ai a pre-loaded normal antinuke silo -- which is impossible to do in skirmish. NONE of my hacked antinukes worked in skirmish for the ai, although I did make a working player-useable super-antinuke.

The Ai cheats using unfair hacked units in the AI_Cheats.ufo and Ai_TACConly.ufo. These include starting resource providers and hacked cloaking fusion reactors. It is IMPORTANT to note that the ai is limited to 1 (or 2 on hard) special starting resource buildings. The starting resource buildings provide a massive +25 metal and +500 energy each (or half that on easy) to sustain the ai's production until it can build level 3 resource units - but since it only builds 1 or 2 of them, killing them causes the ai an almost instant resource crunch. (Note: Core's hacked resource building makes +30 metal and +600 energy to cover for its disadvantage against an Arm ai that likes to rush.) The hacked cloaking fusion reactors are cloaked but not stealth (they show up on radar, in other words) and provide +2 metal (but use -100 energy/sec to make that metal) (only +1 metal at -50 e/sec cost for Arm's) and +2000 energy for the same cost as the normal cloaking fusion reactors. The tiny metal production is to encourage the ai to build them over regular fusions and metal makers. These super-powerful fusion reactors are to sustain massive late-game energy consumption typical of a very large base. (IE- Vulcans, berthas, nukes, Moho metal makers, etc...) It's a good thing the hacked cloaking fusion reactors aren't any tougher than the originals! The player cannot build but can capture these unfair hacked resource units.

The hacked ai-only Arm vehicle plant has been removed as I decided that it made the ai's base more nuke-resistant if it had more regular vehicle plants than fewer hacked ones.

The ai also has a hacked Core Krogoth Gantry that builds krogoths at 3x normal OTA Gantry buildrate (since the ai DOESN'T assist its factories) and provides some resources to partially cover the extra drain caused by building a Krogoth at an increased rate. The buildrate increase on Krogoths allows the ai to build a Krogoth from start to finish in about 11 minutes - if it doesn't run out of resources! This increased rate is not quite as fast as guarding a normal Core Krogoth Gantry with the Core (or ARM!) Commander and 1 Advanced Construction K-Bot.

ALL the ai-only buildings have slow regeneration just like the commanders do. This is even slower than a construction unit could repair them and costs a tiny amount of energy. (-4e/sec)

Although this cheating ai has a mucho-unfair amount of resources, the endgame stats may show something odd -- the ai often ends up with little wasted metal. Unlike most other hacked ai's, it's possible to out-produce the ai resource-wise by the 40 minute mark using a fusion/moho metal maker combo. Even given nearly unlimited buildtime, (like 1+ hours) on hard the Arm ai will make only about +200metal/second and +15,000energy/second while the Core ai will make about +300metal/second and +20,000energy/second. Core needs the extra metal production for Krogoth and Goliath production and the extra energy to run Buzzsaws.

This is STILL a work-in-progress, so it WILL get better in the future and not neccesarily through better hacked units! I find there's still lots I can do on the ai profiles, particularly on unit balances.


Difficulty:
----------
There is MANY ways to control the overall difficulty of this ai.
The Easy/Medium/Hard settings is the obvious way.

Easy - NO nukes, Berthas, EMP silos, Neutron silos, and few factories and construction units. ALSO, the resources provided by any sources are HALVED. Limited to only 1 hacked starting resource building, but may occassionaly build 2 (this is a game bug).

Medium - limited use of nukes, Berthas, EMP silos, and Neutron silos. Factories and construction units are hardly affected. Limited to only 1 hacked starting resource building, but may build 2. ALSO, the resources provided by any sources is only 70% of normal.

Hard - is HARSH, there ARE limits on nukes, Berthas, EMP silos, Neutron silos, Factories, and construction units -- but the ai is still allowed to produce a considerable number of each. Although limited to 2 hacked starting resource building, the ai will occassionally build 3!

Another important consideration is the ai's starting resources. If the ai starts with 10k resources, it will attack earlier and sustain its attack and building production for longer. If only 1k, the ai will have an early attack but it generally will grow slower and its attcks will be smaller and with fewer reinforcements. If you want a slightly longer wait before the ai becomes a threat, start it off with 200/200 resources.

Another way to decrease the difficulty of the ai is to dumb it down by removing the ai-only ufo files.
You don't want to see any enemy bombers, remove Ai_Air.ufo.
You don't want the ai to use mobile jammers, remove Ai_Jam.ufo. (Ai jammers are removed as they are a base part of TA Bugfix and UberHack!)
You don't want the ai to be able to use nukes, remove Swi_nuke.ufo.
You don't want the ai to use fast-building Krogoth gantries (on hard, this means Core probably won't build krogoths at all), Core cloaking fusions, or ai-only seaplanes -- remove Ai_TACConly.ufo.

Counterstrike *WILL* work with just AI_CHEAT.UFO -- without it, the ai's commander does nothing.

Also, standard metal and nonmetal land maps are where the ai functions best. On water maps, the ai produces slowly even with the extra production gains. And on Acid, Hover, and Urban maps the ai will build even slower. Worst of all are air-only maps, because the ai does NOT have air plants that build at an increased rate as players would.

Helpful for the ai is the 500 unit maximum patch (totala.ini file).
This allows the ai to build an extremely large base and attack force, if given a chance.

Probably the hardest difficulty imaginable with this ai would be:
Game set to HARD difficulty.
9 ai's allied together vs the player. (Some Arm, others Core)
Large, nonmetal land map with few good metal spots.(Painted Desert?)
All the ai's start with 10k resources.
The player starts with only 1k resources. (or less!)

I'm not saying that such a setting would be unbeatable, but
I imagine it would be EXTREMELY hard to do so!


Units used by the ai and located in the UFO files:
-------------------------------------------------

SWI_NUKE.UFO

Unit abbv.	Unit# WEAPON NAME		WEAPON ID #/info
AAISILO 	420	AINUKE		157
CAISILO 	421	AICNUKE		158
AAIEMP	422	AAIEMP		143
CAITRON	423	AICNUKE		158

AI_CHEAT.UFO

Unit abbv.	Unit#
FLUXOR	430
QUARK 	431
AAICKFUS	432

AI_AIR.UFO (now contains only ai bombers, as fighters were little improved if any.)

Unit abbv.	Unit#
AAILANCE	453
AAIPNIX	454
AAITHUND	455
CAIHURC	461
CAISHAD	462
CAITITAN	463

AI_TACConly.UFO	****WARNING! ONLY USE IF YOU HAVE TA:CC INSTALLED OR TA WILL CRASH! ****

Unit abbv.	Unit#
CAICKFUS	434
CAIGANT	435
AAISNIPE	444	Ai-only Shooter (this one cloaks!)
AAISEAP	456
CAISEAP	466
CORDEK	445	CORKROG_ROCKET	* Decoy Krogoth,  buildable by the player (menu 3:1)

NOTE: Despite the warnings you might receive when scanning CS's ai units with TA Conflict Catcher/Crusher or the like, the weapon ids used by CS ai conflict only with UNUSED orphan weapons.


I am unsure how to define CS ai so that I'm not describing all hacked ai's in general. I cannot say "it cheats" and be satisfied without considerable explaination for why it cheats.

Because of severe limitations I put on how much this ai cheats, I had to make a lot of compromises to do as much as possible with as little as possible. (I had to design this ai's ai profiles the same way I do nonhacked ai's.)

The special ai-only units give the ai capabilities normally unavailable to the ai but taken for granted by players.

Hacked units add abilities the ai should have but doesn't: cloaking fusions that cloak, bombers that actually drop bombs occassionally, nuke silos that nuke, jammers that don't act like buildings, and cloaking fusions that actually cloak.

Players often speed up the buildrate of troops by guarding a factory with their Commander or some c-units. An AI can't do that. That's my "justification" for the Ai-only vehicle plant and Ai-only krogoth gantry in CS ai. It's the only way for the ai to do what a player does easily: guarding factories with c-units.

The fluxor is a hacked galactic gate.


What is Counterstrike?
(and a comparison of CS ai to BAI)
Purpose of ai:
-------------

CS ai is my counterproof to accusations that I was copying BSR's BAI to make a "super ai". Developement of it started about the same time as BAI, but almost everything similar to parts of BAI were made from earlier sources and done for different reasons.

BAI sustains its base production with ai-only c-units, factories, solars, and metal extractors that produce more than the equivalent normal units. It is allowed to build many of these and builds more and more of them as the game progresses. This makes BAI's resource model almost open-ended, with only unit max and mapsize limiting how quickly the ai can make and consume resources.

CS ai builds 2 special resource storage buildings (the fluxors) that provide a VERY good starting income, (+62 metal/sec and +1200 energy/sec) and builds normal fusions, hacked cloaking fusions, normal moho metal makers, and normal moho mines to sustain its late-game production. For the first 10 minutes or so, the fluxors produce more resources than the ai can consume -- filling up (hopefully) to nearly their max storage capacity. After that, the ai is in a mad rush to build late-game level 3 resource providers before hitting 0 resources.

During that time, its attack force grows first at a steadily INCREASING rate then at a DECREASING rate down to almost no attack force production at all because of a lack of available resources. By 40 min, "ordinary" resources often end up providing more resources than the ai's 2 fluxors. It uses no hacked c-units, a hacked krogoth gantry (so the ai can make krogoths BEFORE the cows come home...), and 2 hacked resource buildings per side  -- both of which have very strict limits. The hacked krogoth gantry in CS ai is useable by players if they can capture them. (I had to discover how to do this on my own, since BAI v4.0 lacked player-useable factories.) There's a limit of 2 on fluxors and 4 cloaking fusions -- a fluxor is roughly equal to 2 ai-only solars and 2 ai-only metal extractors with the BAI on hard -- and BAI doesn't stop with 4 solars and 4 metals either! CS ai's resource model shows a resource production curve that is almost flat (+60 metal/sec and +1200 energy/sec) for the first 15 minutes of the game, and levels out around +200 metal/sec and +12,000 energy/second after about 2 hours of unmolested building. CS ai's resource growth is so slow that reclaimation of wreckage can speed up its growth considerably.

(NOTE: Most other hacked ai's never have a metal shortage so they don't even reclaim wreckage at all! This can cause their base to become blocked by unreclaimed wreckage.)

My goal behind CS ai diverged away from BAI's goal (an ai to kill anyone), when I decided that an ai made STRICTLY to beat BAI wasn't fun to play against. I played such an ai on accident once: Mephisto gave me a special c-air to use while testing ai's. It flies and builds extremely fast and is invulnerable to almost everything via a damagemodifier=0; line. I use it to test "what if" scenarios versis the ai. Unfortunately the first time I used it, I forgot to prevent the ai from building them which resulted in the ai hitting 500 unit max in under 5 minutes.

I watered down the original CS ai to be something barely beatable by above-average players who used some but not all anti-ai tactics. (The original fluxors made +32,000 metal/sec and +64,000 energy/sec and the original Arm ai vehicle plant produced units at 10 times the rate of the standard Arm vehicle plant.) An expert might be able to beat CS ai on a large map without using any anti-ai tactics at all. It is worth noting that just like BAI, CS ai is EXTREMELY hard to beat on certain maptypes - namely nonmetal maps with no metal spots to build on. Those Fluxors go far in handing CS ai a win!

MadRat, Creeperman, Mephisto, and Speed are the 4 guys behind many cool ideas in CS ai. 

Speed created the first known (to me!) ai-only unit, the ai nuker -- a nuke silo that the ai can build that works. I had added 3rd party unit limit/weight entries even before the ai nuker was out, but those units were buildable by the player as well.

MadRat came up with the hacked ai-only bombers that use an increased LOS to find targets from outside missile tower range. (Up till that point, we thought the ai always had perm LOS!) I took that one step further and applied it to all armed aircraft normally found in the game.

Creeperman came up with the ai-only jamming units that use a 0-damage weapon so they chase the attack force around. (Now the ai's attack force doesn't always show up on radar...) Creeperman and I worked to add better badtargetting lines to the ai bombers so they would be MORE likely to destroy vital targets first (assuming they get only one pass.) He also helped me work the bugs out of the ai-only nuke silos. I came up with the ai-only EMP silo and Neutron silo -- a simple offshoot of the ai-only nuke silos. If nothing else, the ai-only EMP silo has an annoying habit of draining player's antinukes in human vs ai games. Lastly, I came up with ai-only cloaking fusions because the ai NEVER cloaked the original cloaking fusions but did landmines -- however I found out that unless I changed the cloakcost, the ai would have to pay -450 energy/sec (-550 for core's!) even while the cloaking fusion was being built which could take ~10 minutes of gametime thus using up about 250,000 energy to keep it cloaked before it was finished. The ai cloaking fusions make twice the energy of regular cloaking fusions, produce +10 metal, (only +5 metal for Arm's!) and cloak for only -1 energy all for the same cost as the original cloaking fusions. (But they must pay the cloaking cost even while being built -- giving the appearance of adv. c-units building nothing. :) Last but not least, I made a cloaking ai-only Arm Shooter (that cloaks for -1 energy while still and being built and -200 energy while moving) that is easily among the most annoying things the ai can do to a player -- big blue lasers shooting from out of nowhere. :p

LOS.TDF is also a BUGFIX for TA, it adds the missing sight radii out to the range of a Core Leviathan - so units are no longer so blind. It should work ok even in multiplayer. Mephisto made the first from-scratch LOS.tdf table -- I never understood the LOS table, although he tried diligently to explain how TA uses them. Supposedly, the LOS file contains information about viewing ANGLES as well as viewable area stored in a matrix array...

>How do your improved bombers work?
TA's ai somehow uses the bomber's LOS radius as its "scanning" radius for potential targets. Because previously the original bombers' LOS were shorter than their bombing runs, the bombers would more often than not overfly their intended targets THEN turn around and try to bomb it -- which equals almost no chance of success if even 1 missile tower is around. The altered bombers have LOS set as high as 1,500 instead of the original 350. These bombers would be incredibly unfair for the players to have because they'd be using these bombers instead of peepers! Another benifit of the huge LOS radius for the bombers is while they're on their stupid wandering patrols they are FAR more likely to find any lone enemy unit and bomb it than even a player would. I improved on MadRat's designs (he made the first improved LOS ai bombers) by playing around with bad targetting categories so the bombers would be MORE likely to destroy vital targets first (assuming they get only one pass.)

There's only SO much an ai can do versis a good early raid/rush by players. Even BAI on hard isn't immune to them. Creeperman said it was "easy" to totally cripple CS ai with an early raid. CS ai's first mobile attack unit is built in as little as 1 1/2 minutes if it doesn't build an air plant first. This makes it vulnerable to rushing until it gets a sizeable attack force together. After its attack force leaves its base to attack, its base is vulnerable to raiding until defensive buildings are built.


I personally see CS ai as not reliable. While it may get a krogoth in one game in as little as 30 minutes, it may take an hour in the next even though it's not being attacked. Sometimes it builds only 1 fluxor at start, 2, or even 3. These units are EXTREME in the cheating department so I want the ai to have 2, no more than 2, no less than 2 on the hard setting -- and I cannot get that kind of reliability. They're rarely overbuilt but are underbuilt often. Weights don't help much, because of the dreaded build factory failsafes -- once the ai has more than 500 metal in storage and a positive metal income, about all the ai does is build factories.

Sometimes CS ai builds a very early nuke silo. What causes this "randomness" is luck-in-placement of factories, c-units, and the nuke silo. This depends on the numbers of nearby c-units that are willing to assist in the building of the nuke silo -- I've seen 1 nuke silo suck up ever c-air that 2 nearby aircraft plants were making, as well as getting c-vehicles helping as well. Other times, I've seen the nuke silo get built FAR away from any other units and takes a VERY long time to finish. Resources don't seem to be the issue, because the nuke silo's buildcost in per-second terms is so low.

BAI and CS ai perform at their best, relative to players, on different types of maps. BAI is at its "nastiest" on all-metal land maps, whereas CS ai is so little impaired on land maps totally devoid of metal that players are almost guarenteed to be crushed there.

If CS ai reaches unit max (which is rare) or max limits for all units built by one factory type (which happens occassionally), the resources saved (while the factory is shut down) will be used on other projects. So building a DT wall away from your base to keep the ai's ground troops out may result in the ai reaching max limits for those units, thus allowing it to build nukes, berthas, and aircraft quicker.

CS ai uses low limits on all units because I expect the overbuild bug to cause the numbers built to be greater than the set limits. If the ai is not doing well, that will probably not occur -- thus preventing the ai from spending more resources than it has. If the ai is doing well, it can afford to overbuild a few units. I hate it though when it starts building too many guardians, fusions, or moho metal makers at the same time -- either way, it ussually nanostalls for the next 10 minutes are more. I've done a lot in my ai profiles to decrease that from happening through conservative limits on c-units -- but it can still happen anyway because ALL the c-units start building the EXACT SAME UNIT all over the place at the same time. I once saw the ai have 10+ c-units all assisting a fusion being built, only when done to individually start 12 separate HLT's all within 1/2 a screenlength of the fusion. It was the most defended fusion I've ever seen. I guess it went from "build resources" failsafe mode, to less than 100 metal, to patrol mode (which caused the c-units to end up guarding the fusion in the first place, to "build defenses", and it chose HLT's as the defensive type to build.

CS ai, because it does not build any Level 1 (and FEW Level 2) resources, creates a compact base if given enough time. Although its compact base is very vulnerable to nukes, finding the "best" place to nuke can be difficult. Worse still, after the ai is nuked every available ai c-unit will attempt to build replacements for what was destroyed. This can result in one building being replaced by many buildings of the same type. (And you thought Tribbles were bad...)

CS ai still attacks one point in a straight line, but I give it a force that almost nothing (short of a larger force) is going to beat head-on.

As Mephisto said - a hacked ai can easily break almost all the rules of the game. I intend CS ai to partially fix the broken Cavedog ai!


** CS ai's aircraft now have full health. When used with TA Bugfix or UberHack, this shouldn't be a problem as they both include special damage lines for them in their weapons files. HOWEVER, when used with OTA, the ai's aircraft will be harder to kill as they take only default damage from AA units.

Comments? Requests? Problems?
contact me at: Switeck@hotmail.com