Jump to content
XCOMUFO & Xenocide

Alien Ai Implementation And Integration


Garo

Recommended Posts

OK, a bit of a grab bag of comments here (I'm short of time).

 

Item 1. I picked up a book on the weekend about building AIs for games (written by a guy who does it for a living.) His point, you can't make the AI too good. No one wants to play a game where the AI beats you every time.

 

Item 2. How does the AI win the game? Presumably by gaining control of all the countries. But are there any other routes?

 

Item 3. What is a full list of the missions? What is the effect (benefit to the AI) of each mission?

 

Item 4. Implementing regions: possible implementation would be have a bitmap if it's 512 wide bye 256 high, then each pixel represents an area of 80 km per side at the equator. (12,756 * pi / 512) = 78.3 km.

Allow one byte for terain type, another byte for region/country and we have 2 left over for other purposes.

Link to comment
Share on other sites

  • 2 weeks later...
Item 1. I picked up a book on the weekend about building AIs for games (written by a guy who does it for a living.) His point, you can't make the AI too good. No one wants to play a game where the AI beats you every time.
I don't think that's completely true. That's what difficulty levels are for, there's lots of games who have difficulty levels so great where the AI cheats extremely just to beat you, yet still some "easy on the newbie" levels. Plus X-Com was never about being easy on the newbie and people still love it. ;)

As long as you don't make the AI impossible, it should be fine.

 

Item 2. How does the AI win the game? Presumably by gaining control of all the countries. But are there any other routes?
Well the AI wins when you lose. :P

I don't know all the exact details, so I'll just try to contribute what I remember. Either:

- The AI controls all the countries.

- The AI destroys all your bases, thus leaving the world up for grabs. ;)

- The AI gains a lot more score than you do. If I remember, there's two scores: the X-Corps score and the Alien score. (each side gains score for how well they do) Every month you get a report showing the Total Score. (= X-Corps score - Alien Score) If the Total Score is too low, the AI wins.

 

Item 3. What is a full list of the missions? What is the effect (benefit to the AI) of each mission?
Again, I don't know all the exact details, so I'll just try to contribute what I remember:

- Infiltration: The AI will send UFOs to try and infiltrate human governments, instantly controlling it if it succeeds. This obviously works towards the "control all countries" goal.

- New Base: The AI will send out scouts for reconnaissance, and then it'll seriously increase UFO activity while it builds a new base. Bases would obviously serve as another launching point for UFOs and I think the Alien Score goes up while they remain in service. Since the AI can only be defeated on Cydonia, there's always at least one base in operation.

- Supply: The AI keeps his bases supplied with Supply Ships landing at them. This increases the Alien Score?

- Terror: The AI sends an UFO with major forces to terrorize a city. This contributes to controlling the target country and it increases Alien Score while the Terror Site is active.

- Retaliation: The main goal of the AI is to control the world, but if the player keeps screwing up the AI's plans, obviously, the AI will try to counter-attack by attacking an X-Corps base. I'm not sure if the AI will only do this if it has already spotted one or if it will scout for one first.

 

There's also Research, Harvest and Abduction, but these are rather self-explanatory. The UFO goes to its target, lands, does its business, and gives Alien Score and upsets the target country. (depending on how serious the mission is)

Link to comment
Share on other sites

I'll try and clear up the remaining questions and clarify SupSuper's response.

 

Item 2. How does the AI win the game? Presumably by gaining control of all the countries. But are there any other routes?

This is a common error. In fact, it is completely untrue. The OSG lists the reasons for aliens winning the game and nowhere does it say this. In fact, I showed a while back that there will always be one country which refuses to sign a pact no matter what you do. This may be a programming bug though.

 

How you can lose the game (and conversely how the AI can win):

  • In debt of at least one meal-yun dollars ($1,000,000) for two months in a row. :wink1:
  • Two consecutive months with a "bad" score.
  • All your bases are lost due to direct attacks from aliens. (You can dismantle all your bases with no ill effects).
  • Don't finish either of the missions on Mars. (Kinda stupid, but this is how the programmers did it).

That pretty much takes care of that scenario. Onward to Item 3.

Item 3. What is a full list of the missions? What is the effect (benefit to the AI) of each mission?

SupSuper did a good job listing the different mission types. All have one thing in in common though - any activity by the aleins (no matter what type of mission is conducted) all help to increase AI score. It's just that some missions are weighted more heavily. It may be a good idea to take a look at the UFOPaedia listings as they basically spell out the benefits to the aliens:

  • Alien Research: Like the listing says, no threat and hardly no benefit except for a little score.
  • Alien Harvest: The governments don't like this one too much and a successful alien mission results in +30 points to their score.
  • Alien Abduction: Basically the same effect as a harvest except the points are more (+50).
  • Alien Infiltration: This is a pretty big deal. If the aliens are successful in infiltrating a country and signing a pact they gain an automatic +150 points. The infiltrated country also permanently withholds all of it's funding.
  • Alien Base: If a base is built it is an automatic +50 points to the aliens. Also, each day a base exists on Earth there is an extra +5 points added. Monthly, this could add up to more than +150 points.
  • Alien Terror: This is the biggie. If you neglect a terror mission, it adds +1000 points to the aliens score.
  • Alien Retaliation: Surprisingly, this mission doesn't do much for the aliens. It has a big effect on you instead. Losing the base results in no penalty to you score-wise, just money-wise.
  • Alien Supply: One of the least important missions overall. The aliens would be looking at about +3 points to their score.

One other small point about retaliation missions is that the aliens will need to scout for your base first, and the probability of this happening increases with skill level.

 

Hope this helps. :)

 

- Zombie

Link to comment
Share on other sites

Firstly, thank you to Zombie and SupSuper for their contribution.

 

Item 2. How does the AI win the game? Presumably by gaining control of all the countries. But are there any other routes?

This is a common error. In fact, it is completely untrue. The OSG lists the reasons for aliens winning the game and nowhere does it say this. In fact, I showed a while back that there will always be one country which refuses to sign a pact no matter what you do. This may be a programming bug though.

I'm tempted to regard this as a bug and fix it. So, having all countries sign a pact means the aliens win. Any objections?

Edited by dteviot
Link to comment
Share on other sites

None by me. :)

 

- Zombie

Link to comment
Share on other sites

Just throwing some ideas into the mix:

 

(A* Based pathfinding)

 

So essentialy we can treat each country as a node; and each country could have sevral fators that atrribute to the total "Cost" needed to move to that location:

 

1) Size of the country/Region - Larger regions will have a higher movement cost; bigger terrain to cross

2) Alien Infiltration - Countries/Regions that have been infilatrated will have a lower movement cost then those that are not

3) Number of shot down UFO's If a region has too many shot down UFO's the cost of moving through that region/country is much higher

 

So when calculating a path from (Entry point into the atmosphere) to the (Terror,supply,scout,etc point) the path that has the lowest number when all of the three are added is the path the UFO will take...

 

***

 

Just throwing some idea of how a "Smart" path can be taken by a UFO, instead of a dumb straigh line...

Edited by Shinzon
Link to comment
Share on other sites

BTW this thread was the startup of: http://www.xcomufo.com/forums/index.php?sh...2026989&hl=

 

I think all this should be put there in an AI Apendix or somewhere it makes sense.

 

Greetings

Red Knight

Well, the conditions for loosing the game logically go in the section on how to win.

And possibly we need two documents, one for the battlescape, and the other for the rest of the game.

Link to comment
Share on other sites

Just one apendix for each one of them, when required only.. After all both Battlescape and Geoscape are part of the same game.

 

Greetings

Red Knight

I'd argue that it's really two games, the strategic game and the battlescapes. While there are some parts that are common, it's not a lot. For example: The goals in the strategic game (find and stop all UFOs, manage funds, research technology, etc.)are very different from the goal in the battlescape (kill or capture all aliens). In geoscape, events are "real time", in battlescape it's turn based. The only dialog that they have in common is the equip soldier. Thus, to me at least, you need to answer many of the questions the document rasises twice, once for the battlescape, and once for the planetscape.

Link to comment
Share on other sites

Granted, but lets try to find out what we have to replicate when we are doing the document... and if needed we break it in two, than to start it in 2 parts and then discover it would be better to do it in one. And the only way to find out, is doing it.

 

Greetings

Red Knight

Link to comment
Share on other sites

Granted, but lets try to find out what we have to replicate when we are doing the document... and if needed we break it in two, than to start it in 2 parts and then discover it would be better to do it in one. And the only way to find out, is doing it.

 

Greetings

Red Knight

I think we're in agreement. The important point is many of the questions need to be answered twice. Once for planetscape then again for battlescape.

Link to comment
Share on other sites

  • 1 month later...
Item 3. What is a full list of the missions? What is the effect (benefit to the AI) of each mission?
  • Alien Research: Like the listing says, no threat and hardly no benefit except for a little score.
  • Alien Harvest: The governments don't like this one too much and a successful alien mission results in +30 points to their score.
  • Alien Abduction: Basically the same effect as a harvest except the points are more (+50).
  • Alien Infiltration: This is a pretty big deal. If the aliens are successful in infiltrating a country and signing a pact they gain an automatic +150 points. The infiltrated country also permanently withholds all of it's funding.
  • Alien Base: If a base is built it is an automatic +50 points to the aliens. Also, each day a base exists on Earth there is an extra +5 points added. Monthly, this could add up to more than +150 points.
  • Alien Terror: This is the biggie. If you neglect a terror mission, it adds +1000 points to the aliens score.
  • Alien Retaliation: Surprisingly, this mission doesn't do much for the aliens. It has a big effect on you instead. Losing the base results in no penalty to you score-wise, just money-wise.
  • Alien Supply: One of the least important missions overall. The aliens would be looking at about +3 points to their score.

One other small point about retaliation missions is that the aliens will need to scout for your base first, and the probability of this happening increases with skill level.

- Zombie

New question, does the AI loose points (or the player gain them) for shooting down UFOs? If so how much? Does it depend on the Mission? UFO size? If the UFO crashes or is destroyed?

Link to comment
Share on other sites

The AI never actually loses points. It only gains. You get points for shooting down UFO's or destroying them.

 

UFO Type		UFO Dest.   UFO Crash
Small Scout		100		  50
Medium Scout	   150		  75
Large Scout		250		 125
Harvester		  500		 250
Abductor		   500		 250
Supply Ship		800		 400
Terror Ship	   1000		 500
Battleship		1400		 700

 

- Zombie

Link to comment
Share on other sites

  • 1 month later...

UFO Behaviour

 

Hi Gents,

 

I’m currently looking at building the AI, such as it is, for the UFO missions. That is, I’m trying to write code to control the UFO behaviour to make the UFOs act like they do in X-COM.

And I’d appreciate feedback on my understanding (and will also consider feedback about how the UFOs r really SHOULD act.)

 

To begin, UFOs have the following mission types.

  • Alien Harvest
  • Alien Research
  • Alien Abduction
  • Alien Infiltration
  • Alien Terror
  • Alien Supply
  • Alien Base
  • Alien Retaliation

The Harvest, Research and Abduction missions are similar.

  • UFO starts at a random location on the globe
  • UFO proceeds to target site
  • At target site, UFO lands, and waits for a bit. (How long is "a bit".)
  • UFO takes off again, moves short, random distance away
  • Lands and waits for a bit.
  • Steps 4 and 5 are repeated a number of times
  • UFO moves to departure point
  • UFO leaves Earth
  • If UFO is disturbed at a landing site, it will proceed to departure point and leave earth.
  • If UFO is attacked while in the air, and not destroyed, it will continue on its mission.

Questions:

  • Is this correct?
  • Is the number of landings fixed or variable? Does it depend on mission type?
  • Does the UFO ever start at, or end it’s mission at an Alien base?
  • Is the departure point the same place as the start point?
  • Is the start point random? is the departure point?

The Alien Infiltration mission is:

  • UFO starts at a random location on the globe
  • UFO proceeds to target site
  • If UFO reaches target site, UFO disappears.
  • If UFO is attacked while in the air, and not destroyed, it will continue on its mission.

The Alien Terror mission is:

  • UFO starts at a random location on the globe
  • UFO proceeds to target site
  • If UFO reaches target site, it lands, and landing zone becomes a terror site.
  • After a period of time, UFO takes off, moves to departure point and leaves Earth.
  • If UFO is attacked while in the air, and not destroyed, it will continue on its mission.

The Alien Supply mission is:

  • UFO starts at a random location on the globe
  • UFO proceeds to target location. Usually beside, but not IN, an Alien Base
  • If UFO reaches target site, it lands.
  • After a period of time (how long?), UFO takes off, moves to departure point and leaves Earth.
  • If UFO is attacked while in the air, and not destroyed, it will continue on its mission.

The Alien Base (construction) mission is:

  • Scout UFO starts at a random location on the globe
  • UFO proceeds to target site
  • At target site, UFO behaves like a research mission.
  • After a while, UFO leaves
  • Steps 1 to 4 are repeated for a number of “surveying” UFOs
  • A little later, a Battleship UFO starts at a random location on the globe
  • Battleship proceeds to target site
  • At target site, UFO lands.
  • After 4 to 10 days, UFO leaves, and an Alien base is left at the site.

Questions:

  • How many survey craft do Aliens send before the Battleship
  • How many survey craft need to be destroyed before Aliens abandon the construction attempt?
  • Do the survey craft actually land? If so, how many times?
  • Does the Battleship fly to a departure point, or leave immediately?

The Alien Retaliation mission is:

  • “Scouting” UFO starts at a random location on the globe
  • UFO proceeds to target site (somewhere near when Alien thinks X-Corp base might be.)
  • At target site, UFO starts searching the area for a base.
  • If scout is destroyed mission ends.
  • If scout fails to locate base, mission ends.
  • If a base is found, scout leaves area, and
  • Battleship UFO starts at a random location on the globe
  • UFO proceeds to target site (the base)
  • If attack on base is successful, UFO flies to departure point and leaves Earth.

Other questions:

  • Do UFOs ever actively hunt Human craft? That is, do they ever initiate combat with a human craft?
  • Do UFOs ever "detect" human bases just by flying near them, or is it only the Retaliation's scouting mission(s) that can detect a X-Corp base?

Link to comment
Share on other sites

I'll try my best to answer some of these. Here it goes...

 

Harvest, Research and Abduction.

 

Questions:
  • Is this correct?
  • Is the number of landings fixed or variable? Does it depend on mission type?
  • Does the UFO ever start at, or end it’s mission at an Alien base?
  • Is the departure point the same place as the start point?
  • Is the start point random? is the departure point?

The number of times a UFO lands is usually either 0, 1, 2, or 3 times. This depends on mission type, but as of yet we don't understand it fully. The only time a UFO ends at an alien base is when it is a supply mission. Once the Supply Ship finishes stocking the base, it immediately leaves. Departure/start points are random points on the globe and AFAIK they never are the same.

 

Infiltration, Terror, Supply, Alien Base.

 

Questions:
  • How many survey craft do Aliens send before the Battleship
  • How many survey craft need to be destroyed before Aliens abandon the construction attempt?
  • Do the survey craft actually land? If so, how many times?
  • Does the Battleship fly to a departure point, or leave immediately?

Some (if not most) of these questions can be answered by the X-COM Wiki's MISSIONS.DAT page.

 

Other questions:
  • Do UFOs ever actively hunt Human craft? That is, do they ever initiate combat with a human craft?
  • Do UFOs ever "detect" human bases just by flying near them, or is it only the Retaliation's scouting mission(s) that can detect a X-Corp base?

 

UFO's never directly attack X-COM craft. You are always the initiator of air-to-air attacks. Non-Retaliation UFOs do not detect the presence of X-COM bases (it's not their job). Retaliation scouts do the actual detecting, and according to the OSG have a detection range of 240 nautical miles.

 

Some more points:

 

UFO crash sites last anywhere from 1-4 days on a map. Landed UFOs stick around for 4-12 hours, but this number is highly variable and probably depends on mission type and previous X-COM activity on the mission. Terror sites last anywhere from 4-10 hours, but there is a bug in the game allowing you to extend the time-frame to infinity by always having at least one ship headed to the site at all times (I once prolonged a Terror Site a full month until my men went through psi-screening).

 

Technically, on infiltration/base building excercises, the alien base is constructed before the Battleships arrive. Heck, I think it is built before the scouts even show up. I sent one of my craft with unlimited fuel to patrol over a country where an alien base was scheduled to be built and it detected the base long before the ships arrived. This may be a programming glitch of some kind.

 

I think I covered most of it. That link I provided before contains a lot of useful stuff, so it would be wise to study it carefully. Any other questions? Just ask away. :)

 

- Zombie

Link to comment
Share on other sites

Some (if not most) of these questions can be answered by the X-COM Wiki's MISSIONS.DAT page.

- Zombie

Thanks Zombie.

 

Now, to confirm my understanding, This:

ufo-c time-c ufo-type

0/0 1d s.Scout (start of game Research mission is 2.5h*. This is for later ones)

1/0 1w m.Scout

2/0 1w l.Scout

2/1 3d l.Scout

 

Means a research mission will have a small scout, followed by a medium scout a week later (approx), then a large scout a week later, then a large scout about 3 days later.

 

I.e. Missions have mulitple UFOs.

Link to comment
Share on other sites

Now, to confirm my understanding, This:

ufo-c time-c ufo-type

0/0 1d s.Scout (start of game Research mission is 2.5h*. This is for later ones)

1/0 1w m.Scout

2/0 1w l.Scout

2/1 3d l.Scout

 

Means a research mission will have a small scout, followed by a medium scout a week later (approx), then a large scout a week later, then a large scout about 3 days later.

 

I.e. Missions have mulitple UFOs.

Yep, you got it. An exception to this is alien base supply missions. There is only one type of craft, it doesn't land multiple times, and arrives and departs at max velocity. This is like a retaliation Battleship en route to your base. :)

 

- Zombie

Link to comment
Share on other sites

  • 6 months later...

OK, having re-reread the descriptions of missions.dat (and zonal.dat and acts.dat) I think I'm getting a handle on how the Alien AI works.

 

Basic logic goes:

Zonal.dat is used to pick a zone (region) to attack.

Acts.dat is then used to pick the action that will be done in the region.

A sequence of UFOs (as detailed by http://www.ufopaedia.org/index.php?title=MISSIONS.DAT) is dispatched to the area.

 

So, here's my proposed impementation of AI.

 

Now, For every mission, the behaviour is as follows.

1. A position on the Geoscape is chosen (A locus). More on process to choose the locus shortly.

2. UFO proceeds at max speed to the locus.

3. UFO then proceeds to wander around the general area of the locus (at low speed, sometimes landing) for a period of time.

4. After a period of time, if UFO isn't destroyed, the mission (for that UFO) is completed. And UFO departs at high speed. If UFO escapes, the Aliens get the mission points for the UFO.

 

e.g. according to the missions.dat link, a harvest mission will launch 8 UFOs Each UFO that completes it's mission will score 30 points. So if all UFOs are successful, Alien will score 240 points. (plus country, flight time and landing bonuses).

 

Second point, every UFO assigned to the Action will get the same locus.

For most missions, the locus is a land position in the zone. Retaliation missions are a X-Corp base. Supply are an Alien base, And Terror are a city.

For all missions (except supply) once locus is reached, UFO will still fly around the area for a while. (This includes Retaliation and Terror.)

End mission:

Retaliation - move to X-Corp base and attack.

Terror: move to City, drop of terror squad and depart.

 

To prevent a base being built, the final Battleship must be destroyed.

To prevent an infiltration, all UFOs must be destroyed. Otherwise, success of infiltration depends on number of successful UFOs.

 

Any comments?

 

Edit: Final question: What's the score for a research mission?

Edited by dteviot
Additional comment
Link to comment
Share on other sites

Sounds good, and if you successfully counter the aliens you get those points... Quantity of points difference depends on how many missions the aliens dispatch; And extra battlescape ones.

 

Greetings

Red Knight

Link to comment
Share on other sites

Sounds good, and if you successfully counter the aliens you get those points... Quantity of points difference depends on how many missions the aliens dispatch; And extra battlescape ones.

 

Greetings

Red Knight

Er. no. X-Corp get points for shooting down a UFO, but it's based on the TYPE of UFO, not the UFO's mission.

Link to comment
Share on other sites

Second point, every UFO assigned to the Action will get the same locus.

For most missions, the locus is a land position in the zone. Retaliation missions are a X-Corp base. Supply are an Alien base, And Terror are a city.

For all missions (except supply) once locus is reached, UFO will still fly around the area for a while. (This includes Retaliation and Terror.)

End mission:

Retaliation - move to X-Corp base and attack.

Terror: move to City, drop of terror squad and depart.

 

To prevent a base being built, the final Battleship must be destroyed.

To prevent an infiltration, all UFOs must be destroyed. Otherwise, success of infiltration depends on number of successful UFOs.

 

Any comments?

 

Edit: Final question: What's the score for a research mission?

Concerning the retaliation mission: smaller ships are actually scouting for the location of your base. They will not find it if you shoot them down before they get too close (I forget the actual distance, but it's something like 700 nautical miles). Also, the Mind Shield supposedly helps to conceal brainwaves of your troops thus lowering the chances the aliens will detect your base.

 

The probability of the aliens starting a retaliatory action depends on skill level (Beginner: 4%, Experienced: 8%, Veteran: 12%, Genius:16%, Superhuman:20%) and whether or not use make them mad by shooting down too many UFO's in an area. So for instance, if you down a whole bunch of UFO's over the North Pole and your base is in Europe, the retaliation missions will happen over the North Pole even though there is nothing to retaliate against. They can patrol there till heck freezes over and not find anything. But, shoot down the UFO's over your base and the aliens will search for it and may find it.

 

Once your base is located, a Battleship is dispatched to your base every so often. It heads straight to your base at maximum velocity. Once there, if you have defenses built they will activate and attempt to down it. If the defenses fail, the aliens are inserted into the base scenario and you must fight it out with them. If you lose, the base is destroyed and the retaliation battleships are not sent anymore. If you win, the base is saved and the retaliation missions cease (the aliens "forget" your location and must start all over). If your base defenses do down the battleship, the retaliation missions still keep coming. Only when the aliens are able to insert troops into your base will they forget the location.

 

I don't know how many points for a research mission. The OSG doesn't list any numbers for it. It's not much though, something like just the flyby time. Needs more research though... ;)

 

Hope this helps.

 

- Zombie

Link to comment
Share on other sites

Second point, every UFO assigned to the Action will get the same locus.

For most missions, the locus is a land position in the zone. Retaliation missions are a X-Corp base. Supply are an Alien base, And Terror are a city.

For all missions (except supply) once locus is reached, UFO will still fly around the area for a while. (This includes Retaliation and Terror.)

End mission:

Retaliation - move to X-Corp base and attack.

Terror: move to City, drop of terror squad and depart.

 

To prevent a base being built, the final Battleship must be destroyed.

To prevent an infiltration, all UFOs must be destroyed. Otherwise, success of infiltration depends on number of successful UFOs.

 

Any comments?

 

Edit: Final question: What's the score for a research mission?

Concerning the retaliation mission: smaller ships are actually scouting for the location of your base. They will not find it if you shoot them down before they get too close (I forget the actual distance, but it's something like 700 nautical miles). Also, the Mind Shield supposedly helps to conceal brainwaves of your troops thus lowering the chances the aliens will detect your base.

 

The probability of the aliens starting a retaliatory action depends on skill level (Beginner: 4%, Experienced: 8%, Veteran: 12%, Genius:16%, Superhuman:20%) and whether or not use make them mad by shooting down too many UFO's in an area. So for instance, if you down a whole bunch of UFO's over the North Pole and your base is in Europe, the retaliation missions will happen over the North Pole even though there is nothing to retaliate against. They can patrol there till heck freezes over and not find anything. But, shoot down the UFO's over your base and the aliens will search for it and may find it.

 

Once your base is located, a Battleship is dispatched to your base every so often. It heads straight to your base at maximum velocity. Once there, if you have defenses built they will activate and attempt to down it. If the defenses fail, the aliens are inserted into the base scenario and you must fight it out with them. If you lose, the base is destroyed and the retaliation battleships are not sent anymore. If you win, the base is saved and the retaliation missions cease (the aliens "forget" your location and must start all over). If your base defenses do down the battleship, the retaliation missions still keep coming. Only when the aliens are able to insert troops into your base will they forget the location.

 

I don't know how many points for a research mission. The OSG doesn't list any numbers for it. It's not much though, something like just the flyby time. Needs more research though... ;)

 

Hope this helps.

 

- Zombie

 

Thanks zombie. I think it will be useful when I implement Retaliation missions.

Link to comment
Share on other sites

×
×
  • Create New...