AI troop ship issues

Describe your experience with the latest version of FreeOrion to help us improve it.

Moderator: Oberlus

Forum rules
Always mention the exact version of FreeOrion you are testing.

When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Post Reply
Message
Author
User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

AI troop ship issues

#1 Post by Dilvish »

EDIT by Vezzra: split this topic from here.
playerxxcc wrote: also noticed AI still sending troop ships without any protection and with 0 chance to take planet,
Could you please confirm which version you are playing, Also please describe more details of what you see happening, and how often -- for example, if you and the AI had both spotted an undefended native planet, and you happened to beat it there, then it might easily already have had troop ships on the way and they just keep marching (particularly if it hadn't yet observed that you captured the planet).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

playerxxcc
Krill Swarm
Posts: 11
Joined: Thu Feb 12, 2015 9:51 pm

Re: Fighters! Feedback needed

#2 Post by playerxxcc »

i am playing 0.4.7 release candidate. its t300 or something. there is no natives or anything. ai just sent unescorted titan hull troop ships. there is more. another ai made titan hull troop ship with abadoni spices(50% troop strenght). it contained troops of value 19?!? dunno how ai decides what hull should be used for troops, but i doubt its worth to do such troop ships.

i still have save file if its any help. maybe this post should be moved to some other topic or new one, since its not about fighters...

dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

Re: Fighters! Feedback needed

#3 Post by dbenage-cx »

Since it may possibly help narrow that case (and I have not seen this since): I've seen the AI build almost exclusively this design before (titanic troop ships).
This occurred quite some time ago, and was with some possibly incomplete changes (giving some hulls bonuses for specific metabolisms, iirc).

It was very commical trying to fend off such massive amounts of troops (I think one stack had ~10k troops), even lost a couple of planets as I was laughing too much.
If you are seeing this in a release candidate with no other changes, it is sounds worrying.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Fighters! Feedback needed

#4 Post by Dilvish »

dbenage-cx wrote:It was very commical trying to fend off such massive amounts of troops (I think one stack had ~10k troops)
Does it ring a bell if I ask if the AI already had a planet in that system, and was building those troopers there at that planet? There had been some bugginess with the code that handled that particular kind of invasion and could lead to huge stacks. I think we got that fixed (or at least, we tried and I have not seen that happen again since then.)

As for the titanic trooper hull, hmm, yeah it is just going with the cheapest average cost per troop (with a structure constraint to handle projected mine damage); it doesn't currently consider the likely excess/waste from only working with such large hulls. I am pretty sure I see where I could tell it to cap how many troops it should hold in a hull (at standard/generic racial rates), and so perhaps I will go ahead and put in a cap of 32, the amount a Grav hull with advanced pods could hold (at standard rates). If the AI had Eggassem or whatnot available for filling that design it could get up to 64 per ship, but that's certainly far less average waste than with a Titanic hull (and since the AI is still not as careful as a human player the decent amount of structure from a Grav hull is good for its late game troopers).

And as for seeing the AI make troops with Abadoni, I expect that what happened was that the AI was choosing what to build in a particular Resource Group, chose Troopships and then checked and found the best troop species it had available in that resource group was Abadoni. We don't yet have it taking the extra steps of checking around in its other resource groups to see if it had a notably better species to use there and then just building something different in the current resource group.

And, finally, related to the AI having trouble with carriers, was that in a situation where the AI was attacking a combined defense of Planets plus Carriers? That's the AI s weakest point right now; I would expect that in pure fleet vs fleet combat it should be able to assess things reasonably now. I had been intending to try to put in something to deal with that joint defense situation better, but got caught up in other matters. Perhaps I can still squeeze something in, we'll see.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Fighters! Feedback needed

#5 Post by Dilvish »

Hmm, in following up on the trooper issues, it looks to me like I am indeed seeing the AI build half-strength exobot troopers when it could just as well have built full strength troopers.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Fighters! Feedback needed

#6 Post by Oberlus »

Dilvish wrote:And as for seeing the AI make troops with Abadoni, I expect that what happened was that the AI was choosing what to build in a particular Resource Group, chose Troopships and then checked and found the best troop species it had available in that resource group was Abadoni. We don't yet have it taking the extra steps of checking around in its other resource groups to see if it had a notably better species to use there and then just building something different in the current resource group.
My two cents:
Comparing this behaviour with my own way of playing: If I get a better race for pilots or troops, I just won't use anything else, regardless of distance, resource group, etc. The only consideration I make about Resource Group and distance is that I want to be able to produce at max. speed and the best ship designs for the purpose, so I build what's necessary in the best places to get more than one "best spot". Algorithmically, when I get a better race for troops or for pilots, I do as follows:

* For pilots:
- If the just conquered race is in a star system that allows my current best warship designs then
-- Designate that planet as a suitable place to build best warships.
- If there is (another) free planet in another of my systems that is suitable for that newly conquered race and for the desired ship design then
-- Designate that planet as (another) best place for warships and start a colony for the just conquered race in there or send a coloniser from the conquered planet (once it is possible) if desired location is not supply-connected.
- If we don't have a designated planet for best warships then
-- If we already have a populated colony that is not currently designated as the only best spot for troops and that would be the best planet for the new race and desired ships then
--- Designate that planet as a best place for warships and start on it concentration camps (or evacuation) to make space for the newly conquered race. [Usually this last point I only do it for solar hulls that need to be produced in a black hole (which usually I have only one), or for some other demanding energy designs if it is late game and I have no free planets in any blue star system.]
- If we don't have a designated planet for best warships then
-- Find the closest enemy planet that has the necessary characteristics and focus on conquering them. Until it is conquered, choose as temporal best planets for warships those that can produce the second best warship design (apply same algorithm from the start for the second best warship design, but giving priority to the already taken decisions).
- Once a planet designated as best place for warships is colonised
-- Begin producing all the necessary buildings (that will be kept in top of production queue until this algorithm is finished) for the best ship designs.

* For troops:
- If the just conquered race is in a star system that allows my current best troop ship designs then
-- Designate that planet as a suitable place to build best troop ships. [This is always true, since I have low requirements on troop ship designs. Energy frigates is the most fancy I've ever used for troop ships.]
- If there is (another) free planet in another of my systems that is suitable for that newly conquered race and for the desired ship design then
-- Designate that planet as (another) best place for troop ships and start a colony for the just conquered race in there or send a coloniser from the conquered planet (once it is possible) if desired location is not supply-connected.
- If got here and we don't have a designated planet for best troop ships then [something would be wrong in that game]
-- If we already have a populated colony that is not currently designated as the only best spot for best troop ships and that would be the best planet for the new race then
--- Designate that planet as a best place for troop ships and start on it concentration camps (or evacuation) to make space for the newly conquered race. [I have never had to do this.]
- Once a planet designated as best place for troop ships is colonised
-- Begin producing all the necessary buildings (that will be kept in top of production queue until this algorithm is finished) for the best troop ship designs.

Morlic
AI Contributor
Posts: 296
Joined: Tue Feb 17, 2015 11:54 am

Re: Fighters! Feedback needed

#7 Post by Morlic »

Dilvish wrote: I am pretty sure I see where I could tell it to cap how many troops it should hold in a hull (at standard/generic racial rates)
You probably got it right, but just in case: The _rating_function() of the corresponding ship designer is the place to do things like that.
In

Code: Select all

    def _rating_function(self):
        if self.design_stats.troops == 0:
            return INVALID_DESIGN_RATING
        else:
            return self.design_stats.troops/self._adjusted_production_cost()
just consider max(self.design_stats.troops, MAX_TROOPS_PER_SHIP).


Regarding the troop ship issues, it wouldn't hurt if you guys attached logs and/or savegames.
And, finally, related to the AI having trouble with carriers, was that in a situation where the AI was attacking a combined defense of Planets plus Carriers? That's the AI s weakest point right now; I would expect that in pure fleet vs fleet combat it should be able to assess things reasonably now. I had been intending to try to put in something to deal with that joint defense situation better, but got caught up in other matters. Perhaps I can still squeeze something in, we'll see.
We currently do not "accurately" calculate combat strength when fighters are involved. The heuristic I implemented seemed to often provide reasonable results but it is perfectly possible that it is far off from the true result in specific cases. The problem starts that when we consider fighters, we have some quite nasty statistical effects (do we hit fighters, which weapon hit fighters/ships, do we hit carriers? can the carriers launch more in the 2nd turn?) that generally seem to depend not only on 1 fleet but on the composition of the enemy. Deriving an accurate single rating as metric for a fleet strength and from that derive the outcome of a battle is far from trivial.

Some solid mathematical analysis wouldn't hurt in order to derive a more accurate metric/rating. My approximations and sets of differential equations so far ended up either with no analytical solution to work with or stuff that is way too coupled to the enemy fleet composition or was simply less accurate than the crude heuristic that the AI currently uses.

Long-term I want to simulate battle results before an attack order is given / double check if a fleet is strong enough for a military order (cf. https://github.com/freeorion/freeorion/pull/1175 for the basic idea) and hope to implement that until next release. Basically we would still mostly work with some estimated strength rating but if it turns out that the fleet allocated would lose the battle, we would then do a second (n-th) allocation round with a target rating increased by a factor of 2 or so until we are confident to win the battle without many losses (given the currently known composition of the enemy). I envision the simulation would also be used as a decision-making tool to decide if we need to build carriers, flakships, gunships or cannon fodder decoys to "optimize" our fleet composition against either some imaginary or very real enemy.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

playerxxcc
Krill Swarm
Posts: 11
Joined: Thu Feb 12, 2015 9:51 pm

Re: AI troop ship issues

#8 Post by playerxxcc »

another problem with troop ships i noticed. many times ai send troop ships 1 jump to target system (if that is ai plan, who knows... maybe it just wait for his force to come...). ofcourse, i send ship there and start destroying troop ships. even if i dont finish destroying them in 1t ai still dont retreat them home or somewhere else with some protection...

Post Reply