Page 3 of 3

Re: More Varied AI Research Paths

Posted: Fri Apr 27, 2018 10:05 pm
by harpy eagle
sven wrote:(Tricks like the one in init_production_desire.ships() rely on the fact that _ENV behaves differently when an ai_context call is executing than then it does during file-load.)

Ah, I see. It seems I misunderstood how the temporary AI state worked. Probably should have read the comments a little more closely... "when you access variables inside those functions"

So in order to store something in the temporary AI state you need to assign it to an upvalue when inside an ai_context call, like what is done in init_production_desire.ships().

Re: More Varied AI Research Paths

Posted: Fri Apr 27, 2018 10:12 pm
by sven
harpy eagle wrote: "when you access variables inside those functions"

Yeah, this is a critical piece of low-level magic that comes into effect when working with AI helpers. It's arguably over-complex and over-designed, but, it can also be very handy.

harpy eagle wrote: So in order to store something in the temporary AI state you need to assign it to an upvalue when inside an ai_context call, like what is done in init_production_desire.ships().

Yes. (Though, to be pedantic about it, it's _ENV that's the true upvalue in this situation -- in the case of design_to_ship==_ENV.design_to_ship==SCOPE["temp AI State"].design_to_ship, design_to_ship is formally a field stored inside a table upvalue.)

edit: Um, in lua-parlance, an 'upvalue' is a local that's being accessed from a closure that shares scope with that local. Because they're really a form of local-variable access, 'upvalue' reads and writes can't trigger metamethods. However, if you have a table which is itself an upvalue (which is what _ENV is in Lua 5.2), then reads and writes to and from that table can trigger metamethods. Um, that's why the upvalue distinction matters.

Re: More Varied AI Research Paths

Posted: Sun Apr 29, 2018 3:20 pm
by harpy eagle
sven wrote:edit: Um, in lua-parlance, an 'upvalue' is a local that's being accessed from a closure that shares scope with that local. Because they're really a form of local-variable access, 'upvalue' reads and writes can't trigger metamethods. However, if you have a table which is itself an upvalue (which is what _ENV is in Lua 5.2), then reads and writes to and from that table can trigger metamethods. Um, that's why the upvalue distinction matters.

Ah I see. I was wondering if it made any difference to the interpreter whether a variable in the environment happened to come from the enclosing scope or from _ENV, but that makes sense.

Re: More Varied AI Research Paths

Posted: Sun Apr 29, 2018 11:11 pm
by harpy eagle
Update (276b96e):
  • Added missing entry for Neutronium armor tech
  • Added entry for Vindicators tech
  • Added racial research desires for the Tinker (they like missiles).
  • Fixed Gremak only researching one of either battlecruisers or battleships, now they can potentially research both.

Re: More Varied AI Research Paths

Posted: Mon Apr 30, 2018 6:41 pm
by zolobolo
Error for research path

Save: https://www.dropbox.com/s/d708nkwwz9934 ... d.rar?dl=0

Using mod and DEV steam branch at the same time which might be causing the issue

Re: More Varied AI Research Paths

Posted: Mon Apr 30, 2018 6:43 pm
by sven
zolobolo wrote:Using mod and DEV steam branch at the same time which might be causing the issue


Yeah, you should probably not install this mod ontop of r22263 (the current Steam "in_development" branch).

Re: More Varied AI Research Paths

Posted: Mon Apr 30, 2018 6:45 pm
by zolobolo
sven wrote:Yeah, you should probably not install this mod ontop of r22263 (the current Steam "in_development" branch).

Ok, got it

Removed mod from the folder and the issue has disappeared