Planet trading, refits and AI

A place for discussion of making game modifications.
Juku121
Posts: 3
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: 1511
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: 3
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: 1511
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: 107
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: 1191
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: 10
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: 3
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.


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 0 guests

cron