Jump to content


Photo

Where does the computer pick its 'enemy'?


  • Please log in to reply
15 replies to this topic

#1 Akkrand

Akkrand
  • New Members
  • 61 posts
  • Location:Melbourne, Australia

Posted 06 August 2004 - 03:39 AM

Hi,
I want to find how the computer AI picks it opponent, the one it concentrates on, so as when the computer has multiple opponents, it goes for certain ones above others (ones it can kill easier). For instance if the computer was playing Airforce I wouldn't want him to target Infantry General if there was an America against him, which he could kill easier.
An added bonus would be the comp would be able to 'gang up' when there multiple players on both sides...

Anyone have any idea if this is a script or if it can be changed at all?

Cheers,
Lord Akkrand

#2 Mithril

Mithril

    496

  • Hosted
  • 1,386 posts
  • Location:UK
  • Projects:Heh! You're not going to ask me that question.

Posted 06 August 2004 - 11:23 AM

I'm afraid that is hard coded in the generals AI engine. There is another level of AI in there which of course we cannot edit in any way, we can only plug in the stuff it has to do.

You may, I'm not sure its just a crazy idea, be able to get the AI to choose its target again though. Try the following scripts:

***IF***
<any if condition here to check if this players target acquisition is not effective>
***THEN***
Player <This Player> considers <This Player's Enemy> to be Neutral (or friend)
Set timer <timername> to expire in 0.01 seconds

***IF***
Timer '<timername>' has expired
***THEN***
Player <This Player> considers <Local Player> to be Enemy

so that you somehow force the internal AI engine to check its enemies again. The chance for this to work is very unprobable, unfortunately, but I suppose you get my idea.

Edited by Mithril, 06 August 2004 - 11:24 AM.

Command & Conquer: Red Alert - ReGeneration

"Not the faintest clue =\"

-ComradeJ

#3 Akkrand

Akkrand
  • New Members
  • 61 posts
  • Location:Melbourne, Australia

Posted 17 August 2004 - 11:44 PM

This whole area seems weird... If the computer has multilple enemies, is there no way to differentiate between them? It seems it concentrates exclusively on one player in terms of scripts, but when units hunt they will hunt *any* enemy unit that passes by...
Also, there is no script condition to check whether a player is an enemy!
Thing is, I want the computer to pick one enemy out of multiple enemies to be *the* enemy the computer focuses on; setting the current enemy to neutral may cause problems...

I dunno... I'll mull it over some more...

Also, got another idea for a cool little script series;
Detects the enemy has auroras.
One raptor/mig circles above base, or moves back and forth between base and combat zone, does not attack.
Detects aurora entering base perimeter.
When aurora leaves base perimeter, sets priority of auroras to 5000, hunts for 5 seconds, then goes back to circling (doesn't want to follow all the way back to enemy base, will get shot down).
If it detects you don't/no longer have auroras, hunts normally.

The idea being that the raptor does not attack until the aurora has dropped its bomb and is heading home - once it becomes vunerable. It's useless telling a raptor to guard the outer perimeter against an aurora, it shoots all its missiles whilst the aurora is supersonic, all miss. But if it waits... ...and bides it's time... :ninja:

I've started work on this and have got to test it properly, it seems hard to get the raptor to not attack, but I don't want it waiting on the airfield, then it takes too much time to takeoff, it never catches up....

BTW anyone got any ideas for little things like this that I could try to work out? I'm getting a little bored with nothing exciting to work on, every now and again I gather enough energy to update another general with some of the scripts I've written, but I enjoy working them out more than exporting/importing them into each gen, especially if they require a lot of faction specific stuff...
Ever since I found that I could assign a string local variable to each team, the possibilities of things I could do skyrocketed, now I just need ideas...

Cheers,
Lord Akkrand

#4 Cammy

Cammy
  • Hosted
  • 51 posts
  • Location:Hamburg

Posted 18 August 2004 - 01:18 AM

I might not be that specialized with that Stuff, but... As far as i know and was told, the AI always focuses on that Player who is nearest to them, if there are two or more in the same Distance, the AI will continuely pound on all of them. Sometimes the AI does an Unholy Alliance(RA2 4 Ever :)) with the Player, and will not attack your Units as you attack the same Enemy together :) This is what i could experience several Times :ninja:

Akkrand, if you are really that bored, you could assist me in creating an complete new AI Style for my russian Faction ;)

#5 Mithril

Mithril

    496

  • Hosted
  • 1,386 posts
  • Location:UK
  • Projects:Heh! You're not going to ask me that question.

Posted 23 August 2004 - 01:57 PM

BTW anyone got any ideas for little things like this that I could try to work out?  I'm getting a little bored with nothing exciting to work on, every now and again I gather enough energy to update another general with some of the scripts I've written, but I enjoy working them out more than exporting/importing them into each gen, especially if they require a lot of faction specific stuff...
Ever since I found that I could assign a string local variable to each team, the possibilities of things I could do skyrocketed, now I just need ideas...

Cheers,
Lord Akkrand

<{POST_SNAPBACK}>


What do you mean with "assign a string local variable to each team" ? Sounds interesting...

Ideas... yes I certainly have some.

Commandbutton abilities like the dragon tank's fire wall, the terrorist's car hijack, the helix napalm bomb (hunt using commandbutton ability should work right), the rally point commandbutton (never thought of this eh? :ninja: ), the chinook's combat drop, the tankhunter's TNT attack, the attack\move commandbutton, the missile defender's laser lock, the ambulance's clean toxin, the comanche's rocket pods, the rebel's booby trap and finally the toxin truck's contamination are all, as far as I can remember, unused.

You could also try to implement random rushes, e.g. different unit combinations OR, much more interesting, a factory rush! That means, you tell the AI to send a dozer\worker to the enemy's base and build a(-a) factory(ies) and\or base defence(s). The problem with that may be the dynamic placement of structures - however as I have recently observed, the original ZH AI did this - the demo gen I think places demo traps next to oil derricks. You may want to look into this ^_^

Another, more theoretical tactic (just thought of this) would be to make a list of your teams and their special actions. Then you can take the data from the list and tell the AI to act accordingly. For example, consider this scenario:

1. The AI builds 2 teams .

2. One of those teams gets stuck somewhere in the map, unable to move anymore. You therefore record this data in the list (by giving the team a time counter script in its "On Idle" state, thus when its been idle for some minutes you can add 1 to a counter named.. say.. "MyTeamsAreDumb")

3. The second team attacks and is destroyed in the combat zone - giving you data about the presence of the enemy in the combat zone.

4. Now you use the gathered data to tell the stuck, dumb team to move to a different location or follow a different path, while for the second data you can increase the scripted build priority for a combat zone guard team.

Get my point? You can gather data from a list of experienced situations - and learn from that data. This is special case only - normal cases such as the destruction of the enemy's base will not increase the effectiveness - there isn't much to learn from victory.

If you expand upon this a good bit further, you will eventually end up with having specified many situations and combined with your splendidly developed dynamic attack paths system this should get us a big step closer towards perfectly dynamic teams of the type that humans would use them! :blink:

Effective players have dynamic tactics. If we want an AI to be a good opponent we need to develop a dynamic system as best as we can with the limitations given to us (3 waypoints ..argh).

Another dynamic system would be the recording of fired superweapons and the rate at which the player rebuilds. In other words, we record the effectiveness of our superweapons and adjust them accordingly - strike at different targets not just at the "player's highest cost area".


When LotR:BFME is out, I'll see about its AI. I'm sure there will be little support and many players that want a better AI. The SDI (currently consisting only of me and thudo, while thudo is often busy and msakdillz has vanished) will quite possibly organize a big, centralized scripting endeavour - with both novice and advanced scripters. Currently there are so many small AI's about - each with its own very effective strategies. Merging them all would create quite a ferocious bear!

Edited by Mithril, 23 August 2004 - 02:15 PM.

Command & Conquer: Red Alert - ReGeneration

"Not the faintest clue =\"

-ComradeJ

#6 Akkrand

Akkrand
  • New Members
  • 61 posts
  • Location:Melbourne, Australia

Posted 24 August 2004 - 10:51 PM

Hey,
I posted a long reply to this, going over each of your suggestions, but it was lost when the server went down yesterday morning...
In short, I think there's a lot of very useful ideas there, I'm going to have a look at a few of them, see what I can do.
Regarding the 'local team variable', in Scripting->Misc-> you can set the team state, to any string you like. This string can be tested as a condition in Team->State->is/is not. A lot of things can be done once a team is treated as a simple state machine. For example, I use this on my bombtrucks now, and I used it with the anti-aurora guards.

Can't be bothered posting much more atm; gotta start copy-and-pasting my posts here so I don't lose them anymore, its getting annoying. :(

Cheers,
Lord Akkrand

#7 Akkrand

Akkrand
  • New Members
  • 61 posts
  • Location:Melbourne, Australia

Posted 26 August 2004 - 12:25 AM

Okay, I've been trying to get terrorists to hijack cars and go off attacking with them; as a very early game tactic, this could be very useful.

I've got scripts that, once a terrorist is created, he goes off hunting using the commandbutton, with a priority set that includes all the civilian cars/trucks/etc. No problem; the terrorist goes straight for the car, gets in, the car is owned by the player. Also, if there are no civilian cars on the map, and hence the terrorist does not hunt, he goes idle, that sets off his idle script, which reduces his priority, and sets him off to attack on foot... so if there are no cars to take, the ai will not build as many of the terrorists.

The problem I've run into is that once the terrorist hijacks the car, he ceases to exist, his team has no units anymore (at least that's what the condition say), and his scripts no longer run... he is not idle, he has no state, nothing works. For all intensive purposes, the team ceases to exist. Also I found that none of the obvious status flags - IMMOBILE, IS_CARBOMB, HIJACKED, IS_FIRING_WEAPON went active before or after he hijacks the car.

So I'm left with no team, and a carbomb that is not attached to any team. It does not join a team when I use the

Player '<This Player>' creates a new Team 'Carbombs' from units it has captured. (There's nothing quite like being assaulted by your own captured units!)

action, obviously it does not count as a captured unit because it was a civilian unit initially, not a faction unit.

The one thing I haven't tested, and am loathe to, is using the Player->Hunt->set all of a players units to hunt, as this would require setting a flag, say 'CARBOMBHUNT' to true for a frame, and having a script that would need to be in every team, that when CARBOMBHUNT goes true, it goes back to doing whatever it was is should be doing. That would be tedious in the extreme I should think. :(

This is another time when I've run into the situation of the object status flags not working as I imagine they should - IS_USING_ABILITY/IS_FIRING_WEAPON one of these flags should go true right before the terrorist jacks the vehicle, but even if they did, I lose control of the team anyway.... most frustrating.

Any ideas on a way around this, or am I going to have to test the Player->Hunt option?

Also I'm going to start looking at making the China Tank Hunters use the TNT, but only every couple of seconds - and only for a few frames - so it doesn't interfere with their normal attacks; there's no point using TNT exclusively, their long range attack is much better in most circumstances - if I can somehow identify that they are about to get run over, though, that would be perfect... If only I could have a condition like
"IF closest enemy unit of KindOf 'Vehicle' is Less Than or Equal to X feet away"...

Will try without it though :sad:

EDIT: Also, I've noticed in the debugger that the players are referred to as both 'playerX' and by 'teamWhateverX' where X is not the same, typically with 'playerX' the 'X' is from 0-7, whereas 'teamWhateverX' seems related to the location of the player on startup... can I access a player directly, like 'player1' in Skirmish, or is this not possible?

Cheers,
Lord Akkrand

Edited by Akkrand, 26 August 2004 - 01:05 AM.


#8 Hostile

Hostile

    Benefitting Humanity Simply by Showing Up!

  • Veterans
  • 9,551 posts
  • Location:Washington DC
  •  T3A Founder
  • Division:Revora
  • Job:Global Administrator
  • Donated
  • Association

Posted 26 August 2004 - 01:44 AM

There is alot of good stuff in this discussion, wish i could add something besides praise. Keep up the conversation I am very interested. Hope this is not spam. I will have to script my 3 new factions in the next few months and am all ears...

#9 Mithril

Mithril

    496

  • Hosted
  • 1,386 posts
  • Location:UK
  • Projects:Heh! You're not going to ask me that question.

Posted 26 August 2004 - 06:43 PM

About the TNT thingy:

Yes its much more effective on buildings or as a last resort to deal a bit of extra damage - have you tried using the NO_COLLISIONS object flag? I know, object flags are evil (for reasons unknown to apparently everyone) but this is the first obvious thing. You'd have to put the script action in the "Actions if FALSE" tab, obviously :p
You may be able to do this with an INI modification but it won't be worth it - it may present other problems.

Other than that, damn WB seems to be ambitious to present its limitations again. Let's hope that will change in BFME..


About the carbomb thing:

It won't only be tedious in the extreme but expensive in CPU power too.. setting all the units to hunt will result in.. a lot of pathfinding calculation and similar things. Hmm.. however, setting the player's units to hunt won't be THAT expensive in this case because

a) the player does not possess many attacking units at this stage
b) this won't be done very often, as there is only a limited number of cars to hijack

I have a crazy idea. Not often, but sometimes crazy ideas work. What if you use the "[Player][Transfer]Transfer assets from one player to another player" script to transfer units from <This Player> to <This Player> ? Sounds crazy, it is. But maybe this "reminds" the player that the captured cars are his property.. After it has realized that you may be able to create a team from the captured units. Low chance of success but at least something..

Also, I've noticed in the debugger that the players are referred to as both 'playerX' and by 'teamWhateverX' where X is not the same, typically with 'playerX' the 'X' is from 0-7, whereas 'teamWhateverX' seems related to the location of the player on startup... can I access a player directly, like 'player1' in Skirmish, or is this not possible?


Without looking at it in detail I would say this looks like it is possible because WB is for both single player and skirmish scripting. You can try.. if I remember correctly I tried something like this before and it didn't work in skirmish - to my knowledge the AI engine has to create instances of players from pre entered data - the name and position of starting position waypoints for example, with which to compute the placement and therefore the instances - such a relativity would not allow a direct access, as far as I can tell. But please try and report back ;)

Edited by Mithril, 26 August 2004 - 06:45 PM.

Command & Conquer: Red Alert - ReGeneration

"Not the faintest clue =\"

-ComradeJ

#10 Akkrand

Akkrand
  • New Members
  • 61 posts
  • Location:Melbourne, Australia

Posted 27 August 2004 - 12:19 AM

The 'all units hunt' thing isn't too CPU intensive, I have some 'Blitz Attack' scripts which use it, when the computer detects your base beginning to fall, he sends everything at you so you don't get time to recover... I put it in, forgot about it, then a few days later I was testing something else, and I fell below the critical levels (that the AI uses to decide if you're on the brink), and I got hit by all the units he had guarding the CZ, his base, etc. It took me right out in about 20 seconds once it got there. There was no noticable hit to performance when this happened, but then, hey, my comp at home is an absolute beast so I could probably tell 8 inf gen comps to hunt and I wouldn't notice...

In any case, my idea was to set all units to hunt, then a frame later, correct this for every other team, so it would only be a moment of lag, and yes, it would only be every few minutes. :0

Put in some stuff to test the playerX stuff, also had to add the commandbuttonhunt thing to Tank Hunters, also noticed they've got it listed in the ini as a special ability, so I've also got them using the ability on the nearest enemy object with KindOf VEHICLE, its doing both so one should work. I played and my scripts didn't noticably reduce their range firing ability, maybe I can tweak it back from 15 frames to 10...
Also added in that transfer of assets action in a script that identifies that you've got carbombs.

Cheers,
Lord Akkrand

#11 Lion

Lion
  • New Members
  • 50 posts

Posted 27 August 2004 - 04:04 PM

Maybe adding a team consisting of a carbomb (cant be built), then letting it recruit units from other teams(the team-less carbomb)? its triggering condition would be the hijacker buld and cars around and once its created you could give it orders as usual?
Dunno, just a random crazy idea

#12 Mithril

Mithril

    496

  • Hosted
  • 1,386 posts
  • Location:UK
  • Projects:Heh! You're not going to ask me that question.

Posted 27 August 2004 - 05:55 PM

Hmm yeh though I assume that the carbombs no longer count as active objects. I suppose that the AI engine need to recount its number of units available, probably with the transfer assets script - at least that's my best guess.

BTW Akkrand I see you have a new version of yer AI on your site.. I'll put it up when I get the chance

EDIT: Now that I think about it.. I think people would like to know more about the changes in the new version..uhmm...which one of your new listed features are in 1.15 ?

Edited by Mithril, 27 August 2004 - 07:22 PM.

Command & Conquer: Red Alert - ReGeneration

"Not the faintest clue =\"

-ComradeJ

#13 Akkrand

Akkrand
  • New Members
  • 61 posts
  • Location:Melbourne, Australia

Posted 29 August 2004 - 11:53 PM

I'm trying what Lion said; making the teams 'Carbombs 1-10' as there are 70 different types of civilian cars I can hijack, each team has 0-5 of 7 of them, their build condition is that the player owns some of them, they allow reinforcement to recruit, their oncreate is to guard their base inner (waiting for Launch_attack, so they all go at once), and it also sets the team to recruit anything within 5000 feet... Gonna see how that works.
Mithril, I'm not sure I can really tell you what 1.15 has... 'cos I don't remember :grin: I'm pretty sure its got the latest Dynamic Paths on Vanilla USA & Demo Gen. It might have the anti-aurora guards for all usa & china factions, but I can't be sure. USA gens target commanches and chinooks now, as a friend of mine found to his dismay, and all generals have the blitz attack scripts I mentioned in another post. I reckon that might be all... Oh and there may be some of my target acqusition stuff, but I don't think it works :(, at least it doesn't cause problems.

EDIT: Just to clarify why I don't know; I pretty much work on this every day, a little bit here, a little bit there, while I am at work. Sometimes I do large changes, but they mostly happen at home (like the Dynamic Paths). So some of the changes I make are a direct reflection of what happens in the 4v4 game after work: If attack after attack is repelled by commanches, I tell raptors/migs to target them, if I notice my workmates sending their chinooks to supply docks far from their base, I make sure that chinooks are in the priorities as well, so they get shot down, etc. But by and large, the changes are small and often forgotten - or plain don't work. Maybe when my contract ends and I get some free time, I'll go over one gen a lot, and code him from the start. But only being able to do a little each day makes that impossible, as then after the first day, my new project would be a gen dead in the water, as he wouldn't be a tenth finished.

Cheers,
Lord Akkrand

Edited by Akkrand, 30 August 2004 - 12:18 AM.


#14 Lion

Lion
  • New Members
  • 50 posts

Posted 30 August 2004 - 07:34 AM

From my experience it wont work like that, if a team has 0-x units of a type the player cannot build, it wont build the team period.. add a team with 0-1 pathfinders and other units and until that tech is purchased it wont build the team. Could be only the case for gen points but with 70 civilian cars i guess you are buggered, if only object lists could be used with team creation!
If it doesnt work I guess youll have to make a team for each type of car, at least the ones you see in common maps which should be a lot less!


By the By building outside base/resource areas works by sending a dummy team that can have the AI build something at its location. Coupled with an invisible, AI only unit spawned in the skirmishscripts.scb file that can move very fast, possibilities for building bases all over the place, black market randomization, aggressive tunnel networking and tech building protection all seem too easy...
now try to get the workers across twilight flame in time to rush them :grin:

#15 Akkrand

Akkrand
  • New Members
  • 61 posts
  • Location:Melbourne, Australia

Posted 30 August 2004 - 08:28 AM

You're right, it won't build the team... but I thought it was simply as it was removed from the 'pool' of available teams, and so never chosen. What I've done (gonna test later tonight) is have a script that says:
Build a team <Carbomb Team 1> where Carbomb Team 1 is the name of the first of the 10 teams. I figured it'd force it to create the team, even if it was empty. Then it would autoreinforce with some of the carbombs lying around. We'll see.

What's this AI only-invisible-fast unit? I want one!
I knew how the AI built the teams out there, if I am going to use that somehow, I want to have it move the dozer/worker out there before it queues it, otherwise its a piece of 1 health scaffold waiting to get killed and cost you money.
If you want your worker across a map, make a team with a technical and a worker loaded into it (once someone posts a complete "how-to-load-a-transport"), move it to X position, unload the transport, disband the team. Voila! A worker across the map. You could even tell the script that builds <whatever> to run exactly 1 frame after the team disbands, using a timer. Then you increase the chances that its that worker that builds the <whatever>... hehe would be a waste if another worker, back at base, calls out "Yep! I'll do it, be right there!" then walks.

Cheers,
Lord Akkrand

#16 Lion

Lion
  • New Members
  • 50 posts

Posted 30 August 2004 - 08:34 AM

Well while i cant get units on transports (why god why?? im trying again!)
ill just use a dozer as that team, however im not 100% on its behaviour when the dozer team has scripts running it, even if i disband it, will the AI be stupid and send a dozer from base (since it started constructions while the dozer was still under orders?)
gotta try all that out when i do GLA, for now ill just try and make some combat chinooks/humvees/combat drops/flying ambulances!
good luck with the car issue!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users