Making a purchasing system for IRM. |
Ok, here's the deal. I want to make a purchasing system for the AI of my mod. The old system and the one introduced in 1.25 don't suite my needs, i have just too many ships and unit types for either of thoses to work properly...
Now, i don't really need code from anyone, but to define the basic mechanics to use to state how much to build of what and when. The AI of SEV isn't smart enough to build things to to counter what another player is doing, so all we can do is make it a shopping list that should make it prepared for mostly anything.
So what do you think it should have, how many of each and how much more to buy as it goes stronger... I haven't decided on what the AI should base itself to determine the size of it's fleet... Planets, shipyards, ressources produced, ressources stored, how many enemies it has or how big the neighboor fleet...
So, post ideas.

Re: Making a purchasing system for IRM.
Why not look at your own techniques. Play a game for about 100 turns then look at your own percentages.
For me at that point I think I'd be done with colonization, I'd have 1-3 choke points with a fleets located at each choke point. I'd likely have 1-3 carriers (I like to have space yards on my carriers), and then for the most part the rest are attack ships. I might throw in planet capture ships (bombers, troop droppers). But top of the line attack ships (like 90%-95%). If possible I'd use older attack ships as scouts, or retrofit them.
SEV, more than a feeling.

Re: Making a purchasing system for IRM.
Before you can come up with a 'shopping list', you must determine what kind of AI you're trying to build. As you say, the AI cannot adapt to what other players do. However, if it tries to do everything adeptly, it will fall to any specialist empire. Doesn't mean you shouldn't program some empires to be Generalist, but if all of them were Generalist then it wouldn't be much of a challenge. Better alternative: get them to ally with each other better and trade their strengths. Let the AI know what other AI empires' "shopping list flavour" is and influence diplomacy accordingly. Most relevant in a Mega Evil reaction or an AI Alliance made for some other reason. Inter-Related AI!!!
Now, as for what the different 'flavours' are... here's some thoughts:
- Resources + Production vs Research vs Intel
- Conquerer vs Exterminator (troop transports vs bio/bombardment weapons)
- Fighting Style (seeker heavy vs big guns heavy vs units heavy)
Some colonies can be built up into anything based on its value: those 100~110% planets. Research minded AI shouldn't have any doubts about what to do with such facility space - more RCs. A Production minded AI would instead build up resource facilities there to increase production that little bit more.
Same with research agenda. Certain small tweaks to the basic research choice algorithm would give extra flavour: e.g. Applied Research early or Space Yards? How early to get Planet Utilization/Engineering, or go for Centralised Computer Systems instead?
I'm sure you get the idea with "Conquerer vs Exterminator" so I won't elaborate much on that. The Exterminator doesn't even want to bother colonising what it's razed, so has no qualms with making it a suicidal landscape (Nukes! Plagues!). This would give an extremely huge headache to the player/victim and this AI must be prepared to hurt its own expansion for this objective.
Fighting Style doesn't mean 100% This or That. It means say... 50% of the fleet is made of one type of ship with a full supporting compliment of everything else still in the balance. When you go up against a 30-ship fleet and 15 of them each have 4~6 seekers to unload at once (Lv 10 Frigates or bigger ships), you cannot take any fleet to take that on. A 50% Gunship fleet would never be approached by ships yet they'd still have Point Defence to handle drones/fighters/seekers (and have an edge in range and speed to avoid getting 'sniped' at by Parthian ships). Or maybe even a unit heavy approach, with big carriers/ships full of fighters/drones being the centre stage and 30% (say) Gunships presenting interesting challenges to 100% Point Defence/Secondary Fire fleets.
In general though, the AI should recognise which colonies are/will be important and defend them with lots of satellites, 3~8 weapon platforms and some troops (this makes it an absolute pain to try and conquerer). Extra defence would be a fighter/Gunship combo - preferable if we could order them to NOT charge forward, but stick around the colony they're defending.
Sidenote: that really is a big problem with the AI when it comes to planet defence - they send everything out at once. So I can deal with the fighters separately, then the ships, then the satellite/weapon platform combo. Bases are useless for planet defence (we can maneuveur around them) - their job is out in space.
Yeah... I haven't given any specific build orders. Just the fact that you'll need many 'menus', which individual AIs are built up out of.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Making a purchasing system for IRM.
Unfortunately my new scheme isn't so hot either. Only getting a mixture of colony and attack ships. 
-----

Re: Making a purchasing system for IRM.
Ok, then in the early game (aside from basic colony ship construction):
- Research Space Yards and Mineral Extraction early (IMO), with Applied Research coming a little later
- Pump out mostly "Unit Hunter" ships as Autocannons are extremely effective anti-frigate weapons in the early game when good armour doesn't exist.
- Focus on Satellites and Weapon Platforms for defence. In v1.27+, the AI ought to check how big each colony is and adjust the number of Weapon Platforms and Satellites to build accordingly (a homeworld ought to have 10+ WP and 30+ Satellites defending it by mid-game)
- When it has a solid fleet of "Defence" and "Unit Hunter" ships for self-defence; has a network of "Population Transports" for efficient population management; that is when it should start building "Archer" and "Attack" ships. Decide when it ought to go get Nukes to fit this moment.
As it grows, make sure it has good Space Yards and have them built early on nearly all colonies. Ah but... AI can't build more than 1 facility per turn due to hard coding wasn't it...? Well assume when that's fixed, it ought to be able to pump out ships faster (and sooner after a new colony is set up). This also assumes those new colonies get their population bolstered early, hence make sure there's an efficient Population Transport network.
Research... IMO you don't need to get the AI to tech rush as hard as it can if you can get it to pump out production as hard as it can. All those colonies that finish facility construction should be producing ships unless resources are short (and from my experience, resource management is still ridiculously easy).
With a vast number of ships under its command, it should think about attack or further expansion/consolidation. Always have a defence fleet or two (or more if the empire gets really big), preferably sitting on the homeworld ready to react to invasions. Attack fleets will assemble and start thinking about bloodlust. It must not delay the assault on other empires (hopefully the human player) too much otherwise the tech rush player will have enough advantage to counter the (hopefully) difference in ship numbers. Ditto with Intel rush players.
The AI in v1.25 cannot efficiently manage its empire because it (as far as I understand) can't understand how to manage immigrants to get rid of domed colonies. In fact, I still wonder if it'll be able to tell as all it will be given is "Is Planet Breathable?" which, knowing how atmospheric conversion works, will only consider the citizens' nationality to determine what atmosphere to check against.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.
Re: Making a purchasing system for IRM.
Good points but there is a distinction between neutrals and major players. The above works well for major empires as it posits expansion without over reaching its strength. The only thing I would change is not to build ship yards every where but on any world of 10kt capacity or higher. Planets with a capacity below 10kt are best used for research Intel and resource generation as they will build a ship yard very slowly and due to low population build ships or any thing else equally slowly.
The exception to the above is that al least one ship yard should be built per system as a repair point if nothing else regardless of the size of the available worlds
Neutral powers should colonize every thing they can and research rush after securing the systems warp points with the aim of getting another colonization tech early since they cant expand beyond the one system. Once they have a research base and a good number of colonies they should continue their rush but aim to improve defensive techs. A neutral power wont be able to stand up to a major empire but they should aim to make invading them expensive longwinded and bloody.
Neutrals should also seek to gain advanced military science quickly as a well trained fleet gives them the edge needed to survive and they have a lesser opportunity to acquire experience through combat. Neutrals should never trade colonization techs with any one.

Re: Making a purchasing system for IRM.
Oh I forgot to mention: Space Yards should definitely not be the first thing built on a colony (unless it's designated a Construction Planet whose purpose is to get ships out ASAP). I typically queue them as the 5th or so facility to be built. No point in having a space yard until the population can support it properly.
What is "Expensive Project" anyway, besides the Space Yard issue? Is it unable to follow a build list that says "don't build a space yard until you have 6 other facilities up"?
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.
Re: Making a purchasing system for IRM.
The AI should decide to build Colony Ships on an "As Needed" basis. As in : Oh, gee, there's an open planet here that I can colonize, send in one colony ship! It should also be able to react as in : Oops! Someone else is in the way and killing my ships, I'd better not send a single unarmed Colony Ship through that Warp Point.
As for population transports ... I may be missing something here, but while I've built ships I've put in that class, they were generic freighters for placing satellites. I've never built more than one or two per game. Unless there's a really significant need for freighters, I'd suggest only having one (two or three at most if there's a really big need for them) per system. Otherwise, focus on building facilities and then ships.
The AI's planets should never be idle, either. Once the planet's been built up (which the Homeworld(s) should already be built up) it should focus on ships and units.
Units (satellites, troops, fighters) should also be built "as needed" - empty carriers should recieve some sort of priority for filling with fighters if thats not already the case, prolly 2 troops for every 5kt units of space on the planet, and I'll let you figure out when and where satellites are needed ...
Re: How many freighters should my AI build?
As a player I tend to use a lot twenty or thirty commonly build them during the colonization phase to fill up behind your colony ships have to be that many since cargo capacity is lower than stock. at first I produce them interspersed with my colony ships at my home world (I tend to start with one) and move production to a secondary site preferably in my home system later. Once I have no where to expand to I will refit them as troop and cargo transports. I tend to move population more than any thing else but I do distribute troops and units form a central point particularly if a war starts and there are new colonies in the area.
The problem with the AI is that it will continue to refit them every time a component on them is upgraded and this will slow them down. The only time its worth refitting a freighter is when you get an increase in cargo tech or perhaps storage as that reduces the ships draw on supply depots and they will hang round when they are no longer needed. If you up the priority to build them then the AI will build them every where and block out other things it needs.
I wonder colony type will determine the facility the AI builds on it is it possible to define the ships and units in the same way.

Re: Making a purchasing system for IRM.
You can't edit after someone's replied in the thread. But anyway...
Without going into numbers, my general approach to population transports is to tie them up into fleets in sizes such that each fleet can roughly take how much population my homeworld can reproduce in one turn. Then I'd try to set up a chain where one (and only one) fleet is loading population every turn.
When I no longer need to move population around my colonies so much (but migration is nerfed on default IRM Settings.txt so this won't be anytime soon in normal games) I'd assemble them into one massive fleet that would go out with my war fleet and colony ships so I can make a "War Colony" which immediately starts with 1000+M people on turn 1 (as well as weapon platforms, satellites and whatever other units you want). But I don't know if the AI can be taught to do that so they may as well start scrapping.
Hmm... now how to code this... I'll think about it.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Freighters.
If the AI has a lot of freighters and few planets to dump the extra population, they may end up filling new planets as soon as they are colonized... They may not do it on purpose, but the result would be the same.
Point. Ok then we may as well let it keep however many freighters they had while they were in the heavy expansion phase. Just tighten up basic security (read: make more ships and units) and they shouldn't be easy targets to shoot if they're sitting around planets (with population loaded) waiting for a new planet to be colonised/conquered.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Making a purchasing system for IRM.
Rigid vs Random: both. Half the 'shopping list' is rigid to cover absolute basics. The rest is random so you're never sure what the exact makeup of the AI fleet is. As in, randomise whether each warp point would have satellites, mines, ships and/or fighters defending it; randomised whether the attack fleet is more Gunship, Unit Hunter or Archer focussed, etc.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Making a purchasing system for IRM.
Actually... could you PM me a rough overview of what your purchase algorithm design is? No need for full code, just rough outlines etc. This is worth brainstorming over. Just what is running for each planet that can build something?
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.
Re: Making a purchasing system for IRM.
I'm sorry ... but why must it be run for each planet?
Could it not be done per empire, essentially creating a list of things to build that turn in order of priority? I'd invision that list being limited in number to the number of inactive colonies (colonies not building anything) - then sorted in order of largest cost, with the colonies with the best production getting the most expensive item, working the way down both lists so that colonies with the least production produce the cheapest ships/units?
It might be hard to balance the need for buildings against the need for ships, but if ships/units can be done that way ... with buildings being given a higher priority on planets with empty space ...
Re: Making a purchasing system for IRM.
That it must be done for each planet is I suspect an artefact of the way the AI works in that an empire is a collection of production entities (plants mostly) not an not an individual entity it is however a single entity for such things as research storage of resources and external relations for example. It might be possible however to conglomerate all the individual colony types together so that you only have to write and run a script for all home worlds all mining colonies etc which might speed things up. Not that I know how to do that, but its a thought.

Re: Making a purchasing system for IRM.
Hmm... well this "Super AI start" game I'm in shows 2 quirks so far:
- AI has no concept of which colonies are closest - it's sending out colony ships to halfway across the quadrant when there are fine planets in the same starting system. This won't be a problem in a normal game where you don't have All Vision, but is still relevant for when they get system maps from treaties and when new colonisation techs are unlocked.
- AI doesn't launch everything it can. It's built impressive numbers of units on its homeworlds. But I'm seeing a lot of satellites, drones and mines just sitting on the planet. This is likely due to there already being a unit group in existence and it doesn't want to launch into that. It needs to be taught to "Load Supplies" then "Load Units" off of that unit group, then launch a fresh group with the newly built units.
---
Anyway, from my understanding, the AI doesn't assign a big queue of stuff to build, it just puts 1 item (or a batch in the case of units) each turn when it spots that the colony isn't building anything? Does it put multiple ships in 'queue' at once too, like units?
Fact is, it only puts 1 facility 'in queue' at a time (or at least, only builds one of them at a time). The common facilities (resource production, intel, research) being scaled up (cost, size, production) seems like a good idea yes. Assuming population transport is working properly then new colonies will soon be able to build at 3000+ rate even without a space yard. Until we get Aaron to make better purchasing system code/functions/tools, we'll have to work with this "only 1 facility at a time" issue.
Regarding space yards, as mentioned before they should not be the first thing built. Some basic facilities (e.g. 1 space port, 3 resource facilities and 1 resupply depot) should be set up before a space yard as that will mean the colony will then be likely to divide its time with ships. As I suggested in PM, make orbital Space Yards available earlier so the AI has an easier time building ships and units as well as facilities.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Making a purchasing system for IRM.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Making a purchasing system for IRM.
Doesn't a high AI bonus also give a huge boost to the AI's construction rates? If I recall correctly a AI on high bonus should construct three times as fast, that would make it fairly common for an AI to be able to build more than one ship per turn. I know that I can construct one colonizer per turn in the early game, if the AI does 3 per turn for each colony, it would make a huge difference.
Instead of building a single ship, it could probably build a batch of ships, as it does with units. (if there is ofcourse demand for more than one of those ships)

Re: Making a purchasing system for IRM.
Well, the only ships that could realistically be built that quickly in early game are colony ships with nothing extra on them. Make the AI build them in batches of 2 or 3 then. Those would only take 2~3 turns and it could do with more colony ships in general.
Mmm knowing this, the AI having a huge construction boost doesn't mean much if it doesn't know how to build efficiently. Nothing really new there.
We sure do live with a wretchedly restricted set of AI functions right now... I'm thinking more and more that early Base Space Yards and (slightly) scaled up facilities would greatly benefit the AI. At least, until the core purchase mechanism is improved to allow "build more than 1 item at once" and "abort queue. Do something else".
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.
Re: Making a purchasing system for IRM.
The clean up function I have noticed seems to work in an odd way some times apearing not to at all. This might just be the clean up minister but as the minister and the AI use the same principles I think this is worth looking at. I have for example seen multiple sets of upgrades in a construction que

Re: Making a purchasing system for IRM.
Alright, over-expanding in the early game is certainly a bad thing yes. Ships at present shouldn't be much of a problem I guess - it's rare in early game to build more than 1 per turn and I suspect the AI will upgrade Space Yard tech at the same rate as Bigger Ships become available. "Build only 1 ship per turn" isn't a big concern compared to "Build only 1 facility per turn" so let's focus on that and unit production.
Actually, it needs to know which ship/base space yards are orbiting a planet and which are in an otherwise empty sector... no point building lots of units when there's nowhere to put them. Then again your code can check for cargo space availability on a planet before ordering units - extend that to "check if sector has spare cargo space"? Ship/Base space yards may be best suited to building up ships I guess.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Making a purchasing system for IRM.
Units are only added to queues where there is enough space to accommodate the chosen amount, so they wouldn't be added to a BSY.
-----

Re: Making a purchasing system for IRM.
In other words, it only looks at its queue maker's cargo space. Thing is... IRM space yard components have a small amount of cargo space inherently to them...
And yes, until the purchase system is fixed the AI can't do anything meaningful. I'm winning in that "AI starts with 3 times the Homeworlds and lots more tech" because I'm outbuilding it in ships and its nice advanced tech units don't really stand a chance if they're mostly sitting on some planet's surface. I currently outnumber its ships 300:150 despite the AI having better construction speeds and more homeworlds. It must be taught to build lots of (read: put at high priority) Base Space Yards once it has access to them.
Actually... Fallen Haven, what dictates whether an order for a batch of units gets put up in space or is left on the surface? I'm seeing an AI colony with 9 satellites launched and 50+ on the surface. Not all of them are like that, but this particular colony has meaningless units. Granted, this will be less of an issue when the AI actually builds ships (read: cargo transports) properly.
It defends its Homeworlds impressively. Everything else is... the standard "planets can only build 1 facility at a time" thing I guess... A tiny planet is much better defended (with ships of all sizes as well as units!) than a bigger one. With the AI sending colony ships out to random locations that happen to have good planets, it can't expand fast (this is only an issue in an All Vision game so don't worry).
Final note: are you coding the AI to be different between "Medium" and "Hard" difficulty (chosen at Game Options before starting)? My personal feeling is that the AI doesn't think long enough. v1.29+ will let the game run while we minimise it and multitask. Thus I think you shouldn't be afraid of making the code long but thorough, then allowing users to instead have a 'quicker' version by choosing AI difficulty. I mean, I spend some 15~25 minutes per turn and the AI spends less than 1 minute despite having more colonies to worry about (again, this is largely due to a lack of ships). When there's lots of AI and All Vision is off then yes, it will do better and spend some time but... I wouldn't mind it being longer once I can multitask.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Making a purchasing system for IRM.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.
Re: Making a purchasing system for IRM.
I wouldn’t change any thing major about the mod yet as we really cant yet foresee what the next patch will do and the changes in facility size are one of my favourite things about the mod and I would be reluctant to sacrifice it unnecessarily.
I would concentrate on getting the AI to be more aggressive in wartime if that’s possible. At the moment the AI defends well but it tends to wait to be attacked for far too long when at war.

Re: Making a purchasing system for IRM.
Well... in order for the AI to make an offense, it needs some ships... we can't work on aggression until we get the purchase algorithm sorted so it can actually have a fleet to send out.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.
Re: Making a purchasing system for IRM.
I agree but even when it has a fleet it doesn’t attack with it even when it is at war. This I feel is something which could be addressed sooner rather than later
Re: Making a purchasing system for IRM.
It was more aggressive than this in v0.54 & 0.6 in the current test game v0.8c the Abedon have not attacked me in the 50 or so game years the war has been going on and initially I had hardly any combat fleet only a score of armed scouts scattered over the map.
They have colonies in my systems which I am conquering slowly as they are very well defended and I have the odd colony in their systems which have not been attacked. The only engagements not due to accidental meetings of armed ships at warp points have been my system defence fighters shooting up colony ships and their escorts (all frigiates) and lone scouts. As far as I know the Abedon are not at war with any one except me

Re: I wish i knew what i did wrong...
Maybe it's the reduced sensor range, it has become very small in the last IRM version. The AI probably won't attack unless it can see a colony, or does the AI have a memory for where it has seen colonies or ships?

Re: Making a purchasing system for IRM.
In fact, it should make at least 2 fleets really, so that one can go on the offense and not have to worry about defending because the 2nd fleet will stay behind to get reinforced and defend. Even with the current purchase system the AI knows how to build up full colonies into strongholds (lots and lots of units - just give it a high priority to build weapon platforms, preferably with point defence) that tiny threats can't even think of assaulting.
Really, once it's gotten big enough to even make a fleet that it considers worthy of Offense, it should be capable of building enough ships in response to defence before its empire gets too badly crippled. Empires are resilient things. Truly advanced would be to request (and actually get) reinforcements from other AI allies, but that's diplomacy code which we'll worry about way later.
Therefore the Offense fleet should never worry about the AI entering Defensive mode and just carry on - attacking is in itself a defensive act. Similarly, the Defence fleet should never worry about the AI entering Offensive mode.
Basic Sensors... we've discussed this already yes - a little too nerfed. I suggested that range increases every 2 not 3 levels. Maybe even increase the range of Lv 1 Basic Sensors (back to 3 or up to 4) and make the (now separated from combat sensors) Basic Sensor tech much more expensive. It's the AI that needs vision more than we do afterall. [Edit: Oh ok, so the AI does remember]
Mmm, if I didn't feel so pressured with my time here with RL and other things, I'd take a look at AI programming myself. Taking a look at exactly what new code Aaron introduced would be good though - as in has all his changes been in AI script files that we can change back?
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.

Re: Making a purchasing system for IRM.
Mmm, this is quite insightful why the AI never could do think strategically... Is that "ALL or NOTHING" response done in the AI script alone or is it more hard-wired? Just how much of the AI's stupidity can we re-write?
*glances at the open source IRM AI scripts*
Can we define a new AI State (call it "AttDef" or something) where the Fleets still go on the offense, but unit production is boosted to say 50% and it places a very high priority on deploying satellites, fighters, mines and most importantly - weapon platforms? Ok so it doesn't know how to make ships to anything without fleets, but it can still build ships which simply hover over a planet surface to act as even more garrison - yes?
Such a strategy will at least force the enemy empire to sit and reinforce their offense fleet if they're to continue attacking. This would be risky considering the AI is also attacking and thus, production needs to go into defense too.
---Sig---
Playing Touhou games (Go here if interested . No, nobody else is that good/insane as that replay). No rush for SE V bug fixing.




Re: Making a purchasing system for IRM.
That's funny. I've just finish re-writing the ship purchase scheme for v1.04 of the Balance Mod. I went with a hybrid system of the two functions Aaron wrote that uses demand with min and max caps. The demand is modified by several factors including the AI's state and category. I've haven't compiled it yet, so not sure how good it works yet.
I almost went with an SE:IV style scheme, which is a linear list of design types to build by AI state. The number of items to build is based on the number colonies the player has. I didn't end up going this way since it would a lot more lines of more or less duplicate code and I didn't think the effort would produce anything much different than what exists now.
-----
Space Empires Depot | SE:V Balance Mod