Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: [SOLVED] Triggered AI
[SOLVED] Triggered AI
This topic is locked. You can no longer write replies here.
Aug 18 2011, 8:17 pm
By: newBorn  

Aug 18 2011, 8:17 pm newBorn Post #1



It is not a secret that i'm working for a triggered AI for http://www.staredit.net/topic/14241/

I'm having issues with the system though, What i did: I split the map into 16 areas representing certain regions of europe, ex: Northern Scandinavia.
Each area would have its own "handling" location, now the "handling" location moves within the boundaries of its area and searches for enemies, once it finds one, it issues an order to attack at that location to all soviet units within the area, when the target dies it moves to another target etc (example implementation on the screenshot)



Now whats the problem?
How to force the soviet units to continue forward to a next area when they cleared it. If it was a linear map it would be plain simple, i would just issue an order to go to the next area, but this is not a linear map, its a map of Europe, so if anyone is familiar with the map he will notice we want to force the Soviet Union to for example shift all its forces to Norway when Spain, France and Italy are down, here is where the problem shows up, if we order it to move directly to a location it will just start "patrolling"

example:

Soviet units are in Germany
Since Germany is cleared Soviet forces are ordered to attack France
Soviet Forces wipe out France, lets assume Italy and Spain are already dead,
hence Soviet forces are ordered to attack Sweden as it the only mainland capital left
While on their way there they have to pass throu Germany
Soviet units are in Germany
Since Germany is cleared Soviet forces are ordered to attack France (despite it being already dead.)


P.S - I need a clean and simple solution, giving a gazillion diffrent conditions for each area would be a horrible solution.



None.

Aug 18 2011, 8:43 pm Apos Post #2

I order you to forgive yourself!

Would sending them on a rampage mission work for your needs? Just look it up in the AI scripts.

Edit: It's called "Send All Units on Random Suicide Missions".

Post has been edited 1 time(s), last time on Aug 18 2011, 8:53 pm by Apos.




Aug 18 2011, 9:10 pm newBorn Post #3



Quote from Killer2121
In my version of this map Im making Russia a Human Player. so basically I already solved the problem ^.^

I dont remember giving u permission to edit my map.

Quote from Apos
Would sending them on a rampage mission work for your needs? Just look it up in the AI scripts.

Edit: It's called "Send All Units on Random Suicide Missions".

I'm afraid that wont work since the script works only for normal units, and soviet union uses alot of hero units as well.



None.

Aug 18 2011, 9:16 pm Apos Post #4

I order you to forgive yourself!

Quote from newBorn
Soviet units are in Germany
Since Germany is cleared Soviet forces are ordered to attack France
Soviet Forces wipe out France, lets assume Italy and Spain are already dead,
hence Soviet forces are ordered to attack Sweden as it the only mainland capital left
While on their way there they have to pass throu Germany
Soviet units are in Germany
Since Germany is cleared Soviet forces are ordered to attack France (despite it being already dead.)
I think you should put a condition so that your triggers only fires if a country is not dead. Make it so that if Germany is dead, it will only fire the trigger if France is alive at the same time. This will mean that your units will not be reordered even if they pass through an empty country.




Aug 19 2011, 5:53 am Lanthanide Post #5



Apos has basically got it right. The only way to do this is going to be to have as many triggers in each specific territory as there are external territories.

So for example, Germany will look like this:

If soldier in Germany and enemy in Germany, attack German enemy.
If solider in Germany and no enemy in Germany and enemy in France, attack French enemy.
If soldier in Germany and no enemy in Germany and no enemy in France and enemy in Sweden, attack Swede enemy.
If soldier in Germany and no enemy in Germany and no enemy in France and no enemy in Sweden and enemy in Spain, attack Spanish enemy.
etc.

Each region can have it's own specific order; when France is out of enemies the soldiers will go to Germany, and when Germany is out of enemies the French soldiers will go to Spain next (assuming nationality of soldiers stays constant and doesn't change based on current region; your initial posts implies this is not the case).

Probably the best way to arrange all of this is to use switches, or if you have multiple players, you'll need death counts. Have a unit set aside for each region, and at the start have triggers like this:
If enemy in France (bring), set DC for French to 1
If enemy in Germany (bring), set DC for German to 1
If enemy in Sweden (bring), set DC for Swede to 1
etc.

Then your triggers above can just be "if German DC is 0 and French DC is 0 and Sweden DC is 1" etc.


OR

Because units will only execute the last orders you give them, you could do it in reverse order like this:
For Germany:
If enemy in Spain, attack Spanish enemy
If enemy in Sweden, attack Swedish enemy
If enemy in France, attack French enemy
If enemy in Germany, attack German enemy.

This would give you the right behaviour you want, although it means that you're potentially giving a unit 4 different orders in quick succession, which probably isn't the best in terms of efficiency. I'd probably go with the first approach, because setting up a DC for whether enemies are in an area could be re-used for other trigger systems you might have that could find that information useful.


OR

Actually there's another way, and this is how I do a lot of the systems in my DS Night Fixed map.

De-couple the attacking system from the region system. Do this by creating a new location called "Current target".

Then:
If enemy in Spain, move Current Target location to Spain
If enemy in Sweden, move Current Target location to Sweden
If enemy in France, move Current Target location to France
If enemy in Germany, move Current Target location to Germany

Attack enemy in Current Target

This system is more flexible if you need to add a new country in the future. All you have to do is add a new Current Target location movement trigger, like this:
If enemy is in United Kingdom, move Current Target location to UK.

As I've outlined it, this system won't work if you have two groups of soliders, say some in France and some in Germany, and you want them to attack their own local enemies before they move on to the next country. With the above simple system, this would make all of the soldiers in France and Germany attack the enemies in Germany, before both going to attack the enemies in France. The best around that is to repeat the location movement triggers before each attack trigger:
If enemy in Spain, move Current Target location to Spain
...
If enemy in Germany, move Current Target location to Germany
German soldiers: attack enemy in Current Target

If enemy in Spain, move Current Target to Spain
..
If enemy in France, move Current Target location to France
French soldiers: attack enemy in Current Target

Post has been edited 3 time(s), last time on Aug 19 2011, 6:09 am by Lanthanide.



None.

Aug 19 2011, 9:03 am newBorn Post #6



Quote from Lanthanide
Apos has basically got it right. The only way to do this is going to be to have as many triggers in each specific territory as there are external territories.

So for example, Germany will look like this:

If soldier in Germany and enemy in Germany, attack German enemy.
If solider in Germany and no enemy in Germany and enemy in France, attack French enemy.
If soldier in Germany and no enemy in Germany and no enemy in France and enemy in Sweden, attack Swede enemy.
If soldier in Germany and no enemy in Germany and no enemy in France and no enemy in Sweden and enemy in Spain, attack Spanish enemy.
etc.

Each region can have it's own specific order; when France is out of enemies the soldiers will go to Germany, and when Germany is out of enemies the French soldiers will go to Spain next (assuming nationality of soldiers stays constant and doesn't change based on current region; your initial posts implies this is not the case).

Probably the best way to arrange all of this is to use switches, or if you have multiple players, you'll need death counts. Have a unit set aside for each region, and at the start have triggers like this:
If enemy in France (bring), set DC for French to 1
If enemy in Germany (bring), set DC for German to 1
If enemy in Sweden (bring), set DC for Swede to 1
etc.

Then your triggers above can just be "if German DC is 0 and French DC is 0 and Sweden DC is 1" etc.


OR

Because units will only execute the last orders you give them, you could do it in reverse order like this:
For Germany:
If enemy in Spain, attack Spanish enemy
If enemy in Sweden, attack Swedish enemy
If enemy in France, attack French enemy
If enemy in Germany, attack German enemy.

This would give you the right behaviour you want, although it means that you're potentially giving a unit 4 different orders in quick succession, which probably isn't the best in terms of efficiency. I'd probably go with the first approach, because setting up a DC for whether enemies are in an area could be re-used for other trigger systems you might have that could find that information useful.


OR

Actually there's another way, and this is how I do a lot of the systems in my DS Night Fixed map.

De-couple the attacking system from the region system. Do this by creating a new location called "Current target".

Then:
If enemy in Spain, move Current Target location to Spain
If enemy in Sweden, move Current Target location to Sweden
If enemy in France, move Current Target location to France
If enemy in Germany, move Current Target location to Germany

Attack enemy in Current Target

This system is more flexible if you need to add a new country in the future. All you have to do is add a new Current Target location movement trigger, like this:
If enemy is in United Kingdom, move Current Target location to UK.

As I've outlined it, this system won't work if you have two groups of soliders, say some in France and some in Germany, and you want them to attack their own local enemies before they move on to the next country. With the above simple system, this would make all of the soldiers in France and Germany attack the enemies in Germany, before both going to attack the enemies in France. The best around that is to repeat the location movement triggers before each attack trigger:
If enemy in Spain, move Current Target location to Spain
...
If enemy in Germany, move Current Target location to Germany
German soldiers: attack enemy in Current Target

If enemy in Spain, move Current Target to Spain
..
If enemy in France, move Current Target location to France
French soldiers: attack enemy in Current Target

Well i know this is possible to do this way, but i was hoping there is a way around it, perhaps using grouping points or cloaked unit that leads the attack could be a solution but i dont really know how to do it.

Your option provides me with a minimum of 400 triggers if i just decide to give every territory 5 possible targets (lets say the capitals of playable nations), and if i by any chance decide to give every area the possibility of going to any other accessible area that gives a whooping 4096 triggers...

For just as long at they would be duplicatable it would be fine, but hell, they re not, each territory needs a diffrent priority, for example enemies attacking from balkans should attack Italy first, and then push france, meanwhile enemies attacking from germany should push france first..



None.

Aug 19 2011, 9:08 am Lanthanide Post #7



Well I don't think there's any other way to do it.

If you absolutely need every area to have a unique schedule of targets, then you necessarily need at least 1 set of triggers per area. Then the size of that set is dictated by the number of targets you want.

So you can reduce your total number of targets by giving several areas the same schedule.

In fact, depending on how your map is set up, strictly unique schedules probably aren't necessary anyway. You can simply set up a system of dependencies. Spain is adjacent to France and must go through France to get to Germany or Italy. So you can simply send units from Spain to France, and rely on the triggers inside France to send the units to Germany or Italy.

Post has been edited 2 time(s), last time on Aug 19 2011, 9:32 am by Lanthanide.



None.

Aug 19 2011, 9:08 pm Apos Post #8

I order you to forgive yourself!

Actually, there is an other way. It may make things simpler or more complicated. If I were to be the one making that map, that's probably how I would do it.

Here is the basic idea:
Make square locations from small to big. Put some sort of units to identify each country (That units can be a flag, a building, as long as it doesn't move.). Let's take the flag. Put a flag owned by player 8 on each country.

Now make a trigger that centers the smallest location where the army is at. Then, center that location on the flag located in that small location. (This identifies the country.) Now, center a bigger location and a bigger one and do your test to see if there is a country in there. Verify if it should be attacked. Then, send the units there.

Each time you try using a bigger location, you have to cycle through all the flags.

Make the locations so that each sizes has the potential of reaching the next country.


I believe this is not very well explained... But I don't think I can explain it any better.




Aug 20 2011, 5:04 am Sacrieur Post #9

Still Napping

Apos is speaking of radius detection. You overlap larger locations over smaller ones. Using logic, we can deduce how far something is. Here's an example of a square version:



If the unit is in R6, but not in R5 or lower, then he is 5 matrix squares away.
If the unit is in R5, but not in R4 or lower, then he is 4 matrix squares away.
And so on.

Of course, this doesn't work as well since we're interested in a more accurate result. In the above version, if R6 is true (he is 6 matrix squares away), we can only deduce he is 5 - 7.5 matrix squares away since squares are not equidistant from their center. We can ameliorate this problem by applying more locations in an attempt to smooth out the borders:



Since this is a better approximation of a circle, we have far more accurate detection, but it comes at the price of more locations. The logic, however, remains relatively the same:

If a unit is in any R4 location, but not in any R3 then he is 5 matrix squares away.
If a unit is in any R3 location, but not in any R2 location then he is 4 matrix squares away.

---

Anyway, beyond this I don't know what Apos is saying. But his goal seems to be removing flags from places to attack rather than the logic lanthanide posted. So instead, units will ignore places without flags, but only attack the ones with them. It may be just a guess, but I think he's suggesting some calculation to determine which country is the closest to the army.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[06:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[05:41 am]
Ultraviolet -- 🤔 so inf is in you?
[04:57 am]
O)FaRTy1billion[MM] -- my name is mud
[04:35 am]
Ultraviolet -- mud, meet my friend, the stick
[10:07 pm]
lil-Inferno -- nah
[08:36 pm]
Ultraviolet -- Inf, we've got a job for you. ASUS has been very naughty and we need our lil guy to go do their mom's to teach them if they fuck around, they gon' find out
[05:25 pm]
NudeRaider -- there he is, right on time! Go UV! :D
[05:24 pm]
lil-Inferno -- poopoo
[05:14 pm]
UndeadStar -- I wonder if that's what happened to me. A returned product (screen) was "officially lost" for a while before being found and refunded. Maybe it would have remained "lost" if I didn't communicate?
[03:36 pm]
NudeRaider -- :lol:
Please log in to shout.


Members Online: 9alicee132yB2