More Varied AI Research Paths

A place for discussion of making game modifications.
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: More Varied AI Research Paths

Postby harpy eagle » Fri Apr 27, 2018 10:05 pm

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().

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

Re: More Varied AI Research Paths

Postby sven » Fri Apr 27, 2018 10:12 pm

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.

User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: More Varied AI Research Paths

Postby harpy eagle » Sun Apr 29, 2018 3:20 pm

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.

User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: More Varied AI Research Paths

Postby harpy eagle » Sun Apr 29, 2018 11:11 pm

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.

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: More Varied AI Research Paths

Postby zolobolo » Mon Apr 30, 2018 6:41 pm

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
Attachments
Research path.png
Research path.png (84.22 KiB) Viewed 11974 times

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

Re: More Varied AI Research Paths

Postby sven » Mon Apr 30, 2018 6:43 pm

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).

zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: More Varied AI Research Paths

Postby zolobolo » Mon Apr 30, 2018 6:45 pm

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


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 27 guests

cron