Planet trading, refits and AI

A place for discussion of making game modifications.
Juku121
Posts: 11
Joined: Tue Mar 26, 2019 2:58 pm

Planet trading, refits and AI

Postby Juku121 » Tue Mar 26, 2019 3:39 pm

Hey!

Question number one: how does planet trade via diplomacy work? More specifically, where are the costs for tradable planets calculated? I haven't been able to even give away planets for free; and I'd like to allow planet gifting to any major faction and buying planets from close allies.

Question number two: how can I unify refit costs across instant and manual refits without nullifying the discount system based on number of changed parts? I.e. currently instant refit skips that calculation altogether, while manual takes it into account and is correspondingly more expensive. I don't actually see any skipping for instant refits in the .lua files, so it's some second-order effect (cleverly?) hidden in the code. Or maybe I'm blind? :roll:
Edit2: I'm an idiot. :oops: The refit system counts different weapon mods, not changed parts. What threw me was that the system first calculates refit costs based on full price including mods, gives discounts for old components also with mods, and then does an additional round of discounting for mod differences. And that last discount system does not seem to fully line up with the way weapon mod pricing is usually calculated. \edit2

Edit: Question number three: how does the system for unlocking ship templates via tech progression work? I've tried modifying the 'unlock' in ship template files (specifically, the Tinker Mobile Base which shares its unlock with Starbases) and no changes appear in-game. Is it another case of having to go through the Lua state directory instead of the Mods directory? \edit
Edit2: Yeah, it is. Inconvenient, that. \edit2

I will precede the rest of my post with the caveat that I'm using a modded version of the DLC mod (ver 190314), incorporating a number of other mods (notably akkamadi's extra races and the 'Population manager' UI mod) and quite a few of my own alterations.

The most relevant of my changes are

  1. added a number of "X World Colonization" techs and restricted all races to ca 3 starting types, with new types unlockable by progressing through the planetology tree, at least two of which can be acquired more or less immediately;
  2. changed around ship templates a bit; I'm not entirely sure all my changes are 'safe';
  3. extensively changed all sorts of galaxy generation parameters, including planet distribution, adding 'Huge' planets, modifying starting fleets, infrastructure and population (fun fact: if you overcrowd your starting world, growth goes negative and loses 'growth rate' information, so you cannot make any calculations based on overcrowding 'death rates'; I have a minor UI mod that calculates current growth as a percentage of max growth, which won't work on overcrowded worlds) etc.

I've recently played 180 turns worth of Tinkers on a 300-star map and noticed

  1. AI expansion is really wacky; the two races hardest hit by my colonisation changes are Orthin and Phidi, whose habitat types are rarer; and Yoral can settle most worlds without research; yet Phidi are the undisputed expansion champs (aided by a chance overabundance of water planets near their homeworld), while Orthin are stuck on their homeworld, Gremak and Yoral have small sections of the map with as many outposts as proper colonies; Humans haven't settled anything, Haduir have a passable mini-empire and I haven't run into the Teros yet.
  2. Some of the nonexpanders (specifically, Orthin and Humans) seem to be going around in circles with their fleet(s);
  3. AI appears to be heavily metal-starved, if the diplomacy interface is any indication of the true state of their economy.
Does anyone have an idea what could be the cause of these non-expansion issues (Humans not colonising, some factions doing circles with their fleets, under-colonisation by Yoral and Gremak)? Can I see their tech trees somehow, and do I have to manually add techs to some priority list for the AI before they attempt researching the new colonisation techniques?

Edit3: Continuing the 'answer my own questions' theme, here's what I found:

  1. Orthin: WAD, no Ice or Glacier planets nearby, but they're pretty strong with only one world. Circling is into an anomaly, no clue what it's about, but their entire fleet including the starter colship is into it.
  2. Humans: why they didn't colonise their starter planet, I haven't a clue. Circling is also into an anomaly (how do they even have tech to see these?!)
  3. Yoral: WAD, a considerable lack of nearby non-hostile planets, and then they ran into my own expansion.
  4. Gremak: WAD, an absolute lack of nearby Swamp or Garden planets means they were stuck on their homeworld.
  5. Haduir: WAD, colonised what they could get, which wasn't much.
  6. Teros: holy s***, these guys are on a roll! Bigger than the abnormally-lucky Phidi by a considerable margin.

In conclusion, if everyone researched their low-tier colonisation techs in the first 50-100 turns and could avoid getting stuck in anomalies, things would be more or less normal.

User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: Planet trading, refits and AI

Postby sven » Tue Mar 26, 2019 11:44 pm

Juku121 wrote:Question number one: how does planet trade via diplomacy work? More specifically, where are the costs for tradable planets calculated? I haven't been able to even give away planets for free; and I'd like to allow planet gifting to any major faction and buying planets from close allies.


It's a feature we're yet to unlock. My intent at one point had been to allow planet trading only as part of peace treaty negotiations, but, I ended up deciding that just having the AI decide what planets were going to be part of peace deal was a simpler/better plan. The UIs for planet trading are setup in the game, but, the trade offer tables never populate planets, and I never did setup any kind of valuation rules for planets in the currency exchange logic.

Um... long story short, getting this working well would be non-trivial. The first key thing to be aware of is that what I think you want to do, more or less, is to expand the currency_exchange.lua logic to include coin valuations for planets in some reputation cases. That code is a bit horrifying; because currency exchange policies are fundamentally a bit complex, but, if you can come up with rules for valuing planets in coins, I think editing that code to let the AI negotiate planet prices may be possible.

Juku121 wrote:Edit2: I'm an idiot. :oops: The refit system counts different weapon mods, not changed parts. What threw me was that the system first calculates refit costs based on full price including mods, gives discounts for old components also with mods, and then does an additional round of discounting for mod differences. And that last discount system does not seem to fully line up with the way weapon mod pricing is usually calculated. \edit2


Yeah, honestly, I think the current refit cost calculation rules are not really playing well in practice. I've been meaning to rewrite them more or less from scratch :(

Juku121 wrote:Edit: Question number three: how does the system for unlocking ship templates via tech progression work? I've tried modifying the 'unlock' in ship template files (specifically, the Tinker Mobile Base which shares its unlock with Starbases) and no changes appear in-game. Is it another case of having to go through the Lua state directory instead of the Mods directory? \edit
Edit2: Yeah, it is. Inconvenient, that. \edit2


Yeah, the ship unlock system is "buggy", in the sense that it doesn't properly support live coding or modding. I don't fully understand why that is, but, it's a "known issue".

Juku121 wrote:Does anyone have an idea what could be the cause of these non-expansion issues (Humans not colonising, some factions doing circles with their fleets, under-colonisation by Yoral and Gremak)? Can I see their tech trees somehow, and do I have to manually add techs to some priority list for the AI before they attempt researching the new colonisation techniques?


If you're working from a relatively modern version of the AI, you probably need to tweak research_paths.lua to encourage unlocking of your new paleontology techs. The circling behavior is pretty weird... At a high level, what should be happening is that if the AI calculates potential_colonies={}, the outpost building logic should kick in, and so the AI should expand over the map with outposts. If that's not happening, it probably means there's a bug in the AI introduced by your other changes. I'd start by double checking that empire:could_colonize(planet) is returning the right results in your mod.

Juku121
Posts: 11
Joined: Tue Mar 26, 2019 2:58 pm

Re: Planet trading, refits and AI

Postby Juku121 » Wed Mar 27, 2019 12:10 am

Thanks for the explanations!

I figured out the research_paths.lua bit shortly before reading your post. I'll see if it will make a difference.

So planet trade is half-functional right now... are there plans to fully include it at some point in the future? And is the current list of solutions to shared systems [just bearing it, abandonment, violence]?

The circling behaviour is somehow related to anomalies, as mentioned above. And the humans' refusal to colonise their initial world is still baffling, since it's a nice large Garden in my version. I guess I'll simply force it onto the AI, then.

User avatar
sven
Site Admin
Posts: 1621
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: Planet trading, refits and AI

Postby sven » Wed Mar 27, 2019 12:24 am

Juku121 wrote:So planet trade is half-functional right now... are there plans to fully include it at some point in the future?


Not at present. Tech trading is in a similar place -- I coded up some initial UI logic that allowed it, only to have Arioch convince me that unrestricted technology and planet trading just had too many undesirable gameplay consequences to be a good feature. So, while I know more or less how I'd go about adding planet/tech trades into the game, the current dev consensus is that we're not going to do it.

Of course the tech trade UIs did eventually see the light of day as part of the Herald special event, as that seemed like less-exploitable way of exposing the feature (though it's still arguably a bit broken, imo).

nathanebht
Posts: 120
Joined: Sat Oct 21, 2017 2:48 pm

Re: Planet trading, refits and AI

Postby nathanebht » Thu Mar 28, 2019 1:41 pm

Forget which 4x allowed unrestricted tech trading. I'd trade for a new tech. Then turn a good profit by spreading it around to anyone else who wanted it. Was kinda fun.

Allowing only trading of a tech you've researched yourself is a good limit on things.

Have that limit and that allies should automatically get each other's techs. Probably would work well in SiS. As my games seldom reached the higher techs before I won.

I've never seen a 4x where planet trading was ever actually utilized. Have seen that demanding surrender of a planet utilized in a few 4x. But not trading a planet for techs or something.

User avatar
Arioch
Posts: 1403
Joined: Sun Feb 01, 2015 12:56 am
Location: San Jose, California
Contact:

Re: Planet trading, refits and AI

Postby Arioch » Thu Mar 28, 2019 6:56 pm

Tech trading was pretty common in 4X games (it was in Civilization IV and most earlier versions), but it's becoming less common, because it's a problematic mechanic.
  1. It unbalances the research progression rate. You will progress much, much faster if you can trade for techs, so the progression rate must be slowed dramatically to compensate, but this means that any faction who is isolated or cannot trade due to some other factor (like constant war) will fall hopelessly behind. And if you fall far enough behind that you don't have any techs that anyone will trade for, there's no way to catch up.
  2. It encourages perverse incentives in research decisions. Techs become more valuable for their trade value than for their intrinsic value, incentivising the player to research what other factions will trade for, rather than what the player needs.
  3. Having to regularly check with every other faction to see if they have a new tech to trade is tedious, unnecessary micromanagement.
  4. The player will know much better than the AI which techs are strategically unwise to trade to potential enemies in some situations, or the relative strategic value of techs, providing another opportunity for the player to exploit the AI with bad deals. This is especially the case if you allow techs to be traded for other items or currencies.
  5. Finally, it's unrealistic. Even if another nation teaches you a technology, it still takes time and effort to learn. Some games have moved to providing tech boosts or discounts, which is more realistic, but doesn't resolve the above gameplay problems.
Limiting tech trading to only for other techs, or to techs you've researched yourself, or to only trading with allies, doesn't really fix any of the above problems. Most 4X games like Civilization have dropped tech trading and replaced it with mechanics like mutual research agreements. This allows you to benefit from cooperation with other factions without tedious micromanagement, perverse selection incentives, or the issue of not being able to benefit from such cooperation if you fall behind your partner.

Being able to trade planets (aside from a straight gift or as part of a war settlement) is really just begging the player to exploit the AI.

Alimaeus
Posts: 11
Joined: Sun Mar 03, 2019 2:59 pm

Re: Planet trading, refits and AI

Postby Alimaeus » Thu Mar 28, 2019 10:33 pm

I see what you have said but I would still like the option to trade planets without going to war with someone. I like to set up nice borders :)

I would also like to see some kind of pop trading option, the pop event right now is very RNG and it can take forever to get one of the more useful species for colonising like Orthrin or Phidi or Yoral without starting a war and taking them by force :cry:

Juku121
Posts: 11
Joined: Tue Mar 26, 2019 2:58 pm

Re: Planet trading, refits and AI

Postby Juku121 » Fri Mar 29, 2019 1:26 pm

Four observations:

  1. It was never my intention to allow unrestricted planet trading. I agree that it's hard to even guess what the value of a planet should be, and even harder to teach it to the AI. Unless you are Google, in which case you can probably make a reasonable black-box neural net.
    There are two instances where planet trades seem not too unbalanced and contribute to smoother gameplay: gifts to AI (doable right now, even if the UI is unintuitive) and a counterpart to the demand annexed/splinter colony event. In the latter case an AI you're on good terms with offers you a (not too well-developed) colony in a shared system, so there's less border tension and the player can paint that part of the map in peace. I tried adding something like this, but it doesn't seem to get triggered for some reason.
    Ideally, the player should be able to perform all the diplomacy that's AI-exclusive right now, but that's another topic.
  2. What Arioch said about tech trades is absolutely true, and it is partially the reason I dislike the tech gifting diplo event.
  3. I don't know whether race-specific growth rates work in vanilla, but they don't for me. I'm not much good with Lua, so I just ended redefining them as a local table and overriding the default function behaviour.
  4. More than occasionally, large hourglass maps (300+ stars) have all their anomalies spawn in a single line that goes through the chokepoint. While it might have some bizarre in-universe reason, I kinda suspect it's a bug.

RanDumGai
Posts: 6
Joined: Fri Jul 09, 2021 4:41 am
Location: TX, USA

Re: Planet trading, refits and AI

Postby RanDumGai » Wed Jul 28, 2021 3:02 pm

I know this is a bit of an old post, but as an idea for tech trading, you could add an influence cost to curtail excessive tech trading, much like with the mercenary ships. Endless Space did this, and it made trading tech less desirable, even between allies, as you had to use your hard-won influence to trade. That being said, I feel like influence doesn't accrue fast enough in SiS.

Juku121
Posts: 11
Joined: Tue Mar 26, 2019 2:58 pm

Re: Planet trading, refits and AI

Postby Juku121 » Sun Mar 26, 2023 8:09 pm

Well, I am in the middle of updating to more modern versions of SiS and the DLC mod and...

Something has pretty much broken AI fleets. Only the Orthin are capable of taking their entire starting fleet and at best start patrolling between two nearby stars. The rest sit on their home worlds, colonise some extra planets if there are any in the system, and otherwise pretty much just do nothing. Maybe build some infra. I don't know if they tech up, but probably.

They don't move fleets, they don't build ships, they don't scout, colonise or even build outposts. Despite some having prime real estate right next to them, even with the exocolonisation tech blockage taken into account. It's kinda like last time, except then some of them were still expanding, some quite successfully. Now they've completely frozen up.

Might have to do with me giving them a giant pile of infra, pop and planet size to start with. Maybe the more harsh hostile environment penalties. Maybe Space Expansion Police.

The question is, is there a way to debug this without turning changes on one by one and checking? E.g., how do I check the output of empire:could_colonize(planet) or the various fleet dispatches?

Juku121
Posts: 11
Joined: Tue Mar 26, 2019 2:58 pm

Re: Planet trading, refits and AI

Postby Juku121 » Mon Mar 27, 2023 9:32 pm

Well, after some testing I found the main culprit: some big-brained AI developer made scouts not move if their retreat time was bigger than 1, and even bigger-brained me made the default into 2 without checking. :oops:

I also might have seen a completely vanilla functional_tricks.lua in a mod directory cause the same thing, but I deleted it fast enough that I might have been imagining things.


Now, I have other problems: the AIs scout and colonise and build outposts... But too much scouting and not enough outpost building. After 100 turns, each has at best a small handful of worlds and doesn't really expand beyond that. Most likely because it's a hostile galaxy out there, full of pirates and harpies and crappy planets.

Can I nudge them along somehow? Make them build more outposts... more ships in general. Not scout around in a circle without building outposts.

Better yet, prioritise hostile-world-colonisation techs if there's no usable real estate nearby? Build war fleets to kill weaker pirates?

Also, the Orthin still exhibit the 'patrol between two nearby planets with their entire starting fleet' issue. No idea what's up with that.


Finally, I made the mistake of giving the AI Haduir some Scavengers. Took them some 80 turns to lose their homeworld to the furry pests, and a few more to lose both the other colonised planets in the system. :shock:


Edit: Some more testing. Orthin are still screwed. AIs seem suprisingly vulnerable to rebellion - the Phidi of all things lost their homeworld to grumbling sea horsies! The two dinos seem to be doing best, and that best isn't all that good.

The AI also seems to run into metal deficits way too easily. Even if I give them extra mines at start, they'll sell those and build something else when the going is still good and of course run into a deficit later.

Giving the AI colonisation tech may have helped a little, but not too much.



Edit2: Orthin were running around in circles because their home system had five planets. No idea how that's confusing to their AI, but it is. Others seem to handle it fine.



Edit3: Even more testing. Well, I'll take it back. The AIs are doing about as well as vanilla, considering the severe colonisation restrictions. The one thing that tends to break them is their home planet going into a rebellion and starvation cycle. Not sure why that happens. Otherwise, looks okay-ish, even without giving out colonisation techs for free.

I would still like it better if they prioritised outposts more, and researched colonisation techs if they're low on planets. Where should I look for that?

Also, why do they get these morale issues that can kill a home world in a dozen turns?


Edit4: Starvation, most likely. The AI doesn't seem to handle getting a ginormous home world very well. And I even tried boosting the magical mine-farm exchange to also include other infra. No dice, they'll still starve. Giving them more starter farms seems to work for now. And Scavengers are the bane of the AI. :D

Starvation-induced rebellion seems to be a problem in colonies as well. I mean, I've seen Gremak colonise the same world three times now.

In general, the AI does its job, kinda, but doesn't respond well to a galaxy with relatively scarce colonisable worlds, lots of pirates and other hostiles. It is seemingly not capable of trying to punch through pirates within the first 100 turns, nor focusing on outposts. It sometimes misses colonisables right next door, perhaps because its scouts can occasionally get wedged into a cycle between all the hostile planets.

AIs can also enter a metal deficit for some reason, even trading away their starting mines.

Not sure if this is all caused by a giant hostile galaxy and lots of starter stuff, but it seems so.


It would be handy if I could either see AI planets and research or just take over for a turn. Any way to do that?

Juku121
Posts: 11
Joined: Tue Mar 26, 2019 2:58 pm

Re: Planet trading, refits and AI

Postby Juku121 » Wed Mar 29, 2023 8:47 pm

Okay, I'll try to summarise my questions after all the rambling:

  • Is there a console or stack tracing hidden somewhere? Edit: I mean, general error stack tracing is already there, but an environment where I can call things and they trace any issues they might have.
  • Is it possible to see AI empire details, specifically research and planet details? Edit: there is, ai_dev. Very convenient.
  • Is there a reasonably straightforward way to encourage more expansion and outpost use?
  • How do I encourage the AIs to research colonisation tech, beyond putting it into research_paths.lua? They might not go for 'expansion', after all. Right now, I'm just force gifting them the techs every 50 turns, which is not particularly elegant.
  • How do I avoid AI starvation? Giving them more farms to start with helps, but the problem being present means something is kinda broken. Not sure the magical farm conversion even triggers.
  • Is there something in giant planet sizes (40-60 pop) and giant infra slot numbers (like 20+) that breaks the AI?
  • What's with the metal deficits? I recall that even from playing the unmodded game.
  • How do I avoid AIs going into fleet movement cycles? I've seen two human scouts go back and forth between two stars while the nice garden world right next to their 'homeworld' stayed under the radar. I've seen one of the dinosaurs send out a colony ship and three destroyers to a pirate system, lose the colship, retreat and then repeat for half a dozen times.
  • What might be the deal with Orthin and the fifth planet making them circle with their entire starting fleet?

Oh, yeah, and the place to search for to shrink the rotating planet pane, as asked in the other thread.

Edit2: How do I sort a list? I'd like to sort fleets by ETA, but the fancy sorting that planets have is spread across a few places, and I don't really get how it works exactly. Just sorting by ETA, no extra UI would be fine.


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 9 guests

cron