Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => The Theory of Everything => Topic started by: pblur on February 23, 2023, 05:45:35 PM

Title: How exactly does Blind Research pick techs?
Post by: pblur on February 23, 2023, 05:45:35 PM
Motivation:
In a game I'm currently in, I have no techs I need right now that are Explore. I have some high priority Conquer/Discover techs, and a lower-priority Build tech. I found myself wondering if going Conquer+Discover+Build would make me much less likely to get Explore than just going, say, Conquer. Searching around online, I'm not really seeing the mechanics at play here. I saw somebody say that you can't get the same category twice in a row; is that true? I've never noticed it...

So, how exactly does the game pick a tech in Blind Research?
Title: Re: How exactly does Blind Research pick techs?
Post by: Vidsek on February 28, 2023, 10:27:23 AM
  Excellent question!!  It's been a mystery to me as well.

  Makes me wonder if there could be alternate selection algorithms and if that would would be a good or bad thing.
Title: Re: How exactly does Blind Research pick techs?
Post by: pblur on March 02, 2023, 04:27:10 AM
I know Thinker Mod has an option to tweak the process to some extent, prioritizing the critical exploitation techs like centauri ecology. That option is called 'tech_balance'. I suppose several of the modders must know how this works, but it doesn't seem to be easily available.

If I get the motivation, maybe I'll dig through thinker's code and try to understand it.
Title: Re: How exactly does Blind Research pick techs?
Post by: DrazharLn on March 02, 2023, 12:51:20 PM
The code for this was decompiled by scient in the opensmacx project. Check out the tech_val and tech_ai functions here: https://github.com/b-casey/OpenSMACX/blob/58e36e0bc86a9e050c1cab2d737f7108834ba7c9/src/technology.cpp#L529
Title: Re: How exactly does Blind Research pick techs?
Post by: pblur on March 02, 2023, 08:22:35 PM
Thank you so much DrazharLn! I spent a few hours hunting around the codebase to understand everything, and here's the procedure:

If it's the Formers tech, and faction has either Explore or Build selected, pick that. Otherwise, calculate weights.
Add base weights * focus for each category of tech: tech_Build_Weight * IsBuildFocused + tech_Conquer_Weight * IsConquerFocused + ... (where IsBuildFocused and similar variables are 5 if Build is focused, and 1 if it isn't.)
Modify with the following giant list of conditionals:
Then multiply by 256/TechTier, roll 1d(Weight + 1) for all available techs, and pick the highest (ties broken by 'earlier in the tech list')

Notes:

Note those +PLANET conditionals; those are some DANG good techs that Deidre/Cha Dawn/Caretakers get bonuses to, ESPECIALLY in original Alpha Centauri where Planetary Economics was dependent on Ecological Engineering. This is probably part of why Diedre tends to be a terror.
Title: Re: How exactly does Blind Research pick techs?
Post by: pblur on March 03, 2023, 02:17:07 AM
BWAHAHAHAHA AND NOW IT'S IN MY SPREADSHEET! AND IT ONLY TOOK ME SIX HOURS OF MANGLING GOOGLE DOCS!
 ;danc ;danc ;danc ;danc
(https://imgur.com/j2Jj7vn.jpg)
Title: Re: How exactly does Blind Research pick techs?
Post by: DrazharLn on March 03, 2023, 02:56:17 AM
You're welcome :)
Title: Re: How exactly does Blind Research pick techs?
Post by: pblur on March 03, 2023, 03:31:50 AM
Updated version of the spreadsheet I downloaded off of here and have been using for while now with (mostly) accurate tech odds. I'm not incorporating a couple of factors that haven't been reverse-engineered, and I hardcoded things like 'the tech that gives foils' to their default values. That wouldn't be terribly difficult to change if some modder wants to use this though.

https://docs.google.com/spreadsheets/d/1n7rfYsu_vSj-bMnoL1nnkbckS527FUU7H1X0SrKwqwE/edit?usp=sharing

You'll have to click Make a Copy to use it.

It's immediately quite convenient in my current AAR game. Current Tech:

(https://imgur.com/Ae6WGPJ.jpg)

Suppose I want to focus on Advanced Spaceflight. It's a Discover tech, and focusing Discover gives pretty good odds. On the other hand... it gives a weapon. What if I enable Conquer too?

(https://imgur.com/QC0n5DR.jpg)

Much much better! I wonder why... Let's look at the Tech Tree tab.

(https://imgur.com/nh7GQ50.jpg)

You can see that it has a nice base value from the Discover, but it doesn't have anything impacting it beyond that.

(https://imgur.com/Ln22PJV.jpg)

Here it is with Conquest and Discover on, with that delicious 4x boost from having a weapon unlock.

Title: Re: How exactly does Blind Research pick techs?
Post by: DrazharLn on March 03, 2023, 04:16:12 PM
Neat. I found it interesting how specific the algorithm is. I would have expected something a lot simpler with just a random choice weighted by the tech's Growth/Explore/Conquer/Discover score in alphax.txt.
Title: Re: How exactly does Blind Research pick techs?
Post by: Vidsek on March 03, 2023, 08:27:57 PM
Indeed.  I too was expecting a slightly modified random pattern.  This is much more interesting, I may well start choosing it more often.
Title: Re: How exactly does Blind Research pick techs?
Post by: pblur on March 06, 2023, 02:52:47 PM
One more update of the spreadsheet, courtesy of my brother. He tried using it on a potato, and found that I'd been really inefficient on a lot of the calculations. This is his update, optimized for performance and with a couple of bugs fixed:

https://docs.google.com/spreadsheets/d/1wA6CSoj_O2WrG98fj7HDCvMXl6kaKhMs-klxdDpkk5Y/edit?usp=sharing

Edit: Note that you can configure your setup in the Config page; this supports things like whether you're playing a planet faction, whether you're at war, etc. It also has a checkbox for Thinker's TechBalance option, if you use that.
Title: Re: How exactly does Blind Research pick techs?
Post by: magic9mushroom on June 18, 2023, 03:24:11 AM
Thank you so much DrazharLn! I spent a few hours hunting around the codebase to understand everything, and here's the procedure:
I think I spot a couple of errors here, assuming that code-dump is accurate:

Quote
If the tech has no weights in any category you have focused, and is not a Conquer-weighted tech while you're at war or an Explore-weighted tech while you have 4 or more cities, halve the result.
The Explore condition is "you don't have it focused and you have 4 or more cities", not "you don't have it focused and you don't have 4 or more cities". I.e. if you have 3 or less cities, it decides Explore is "useful" even if unfocused.
Quote
If you have Discover focused (or the map generation settings had low rainfall) and the tech is a prereq (to any depth) to Environmental Economics, multiply weight by x2.
This procs off Build ("wealth") focus, not Discover ("tech") focus.

Note those +PLANET conditionals; those are some DANG good techs that Deidre/Cha Dawn/Caretakers get bonuses to, ESPECIALLY in original Alpha Centauri where Planetary Economics was dependent on Ecological Engineering. This is probably part of why Diedre tends to be a terror.
I mean, yes, she gets bonuses to them, but it's not as great as it might seem. The x2 for the Environmental Economics beeline with Build turned on, combined with those techs' unusually-high Build and Explore values, makes restriction lifting highly favoured under Build or Build/Explore (the latter also favours Industrial Automation due to the Doc:Init x2, and more strongly favours restriction lifting over random other techs like Applied Physics, but practically ensures you will get Doc:Flex ASAP which is meh as a pure Builder).

What Deirdre's bonus does (in vanilla i.e. PlanEco reqs EnvEco) is make Explore and Build/Explore massively favour restriction lifting over everything else, including Industrial Automation and Doc:Flex (but not Doc:Mob; Deirdre still gets that one, because it's a prereq of Planetary Economics). Thing is, though, you want Industrial Automation, and (as Deirdre) ironically also Doc:Flex since she is never a pure Builder - and there's no actual way to prioritise these as Deirdre due to the same Explore that triggers their multipliers also triggering Deirdre's massive restriction-lifting multipliers.

Morgan's x2 to Industrial Automation beeline seems at least as good, and Zak's ability to home in on Pre-Sentient Algorithms (and, to some extent, therefore Fusion Power) with a x4 is pretty notable later on.
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 31 - 840KB. (show)
Queries used: 15.

[Show Queries]