Bug in priority AI (I think)

For test results, bug reports, announcements of new builds etc.

Moderators: another_commander, winston, Getafix

Post Reply
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4652
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Bug in priority AI (I think)

Post by phkb »

In the "oolite-priority-ai.js" file, on line 2543, there is this line of code:

Code: Select all

var adjust = market[commodity].marketEcoAdjustPrice * multiplier * quantity / market[commodity].marketMaskPrice;
But in Oolite 1.81 and following, market[commodity].marketEcoAdjustPrice and market[commodity].marketMaskPrice don't exist any more. Is marketEcoAdjustPrice equivalent to price_economic? I have no idea if marketMaskPrice maps directly to something or not.

Any suggestions on what this calc should be?
User avatar
hiran
Theorethicist
Posts: 2059
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Bug in priority AI (I think)

Post by hiran »

phkb wrote: Sat Aug 26, 2023 9:06 am
In the "oolite-priority-ai.js" file, on line 2543, there is this line of code:

Code: Select all

var adjust = market[commodity].marketEcoAdjustPrice * multiplier * quantity / market[commodity].marketMaskPrice;
But in Oolite 1.81 and following, market[commodity].marketEcoAdjustPrice and market[commodity].marketMaskPrice don't exist any more. Is marketEcoAdjustPrice equivalent to price_economic? I have no idea if marketMaskPrice maps directly to something or not.

Any suggestions on what this calc should be?
Just in case someone wants to see the line in context, it is visible here.

Unfortunately I have no clue about it's semantics.
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4652
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Bug in priority AI (I think)

Post by phkb »

Thanks for that, hiran! Much better! 😁
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Bug in priority AI (I think)

Post by Alnivel »

phkb wrote: Sat Aug 26, 2023 9:06 am
In the "oolite-priority-ai.js" file, on line 2543, there is this line of code:

Code: Select all

var adjust = market[commodity].marketEcoAdjustPrice * multiplier * quantity / market[commodity].marketMaskPrice;
But in Oolite 1.81 and following, market[commodity].marketEcoAdjustPrice and market[commodity].marketMaskPrice don't exist any more. Is marketEcoAdjustPrice equivalent to price_economic? I have no idea if marketMaskPrice maps directly to something or not.

Any suggestions on what this calc should be?
How much do NPCs know about how good their goods sell here?

Probably the closest way to what we have now will be something like this:

Code: Select all

var exDiff = Math.abs(system.info.economy - market[commodity].peak_export) * 2;
var imDiff = Math.abs(system.info.economy - market[commodity].peak_import) * 2;
var distance = (exDiff + imDiff) / 2;

// If closer to the importer, the commodity probably is profitable here
var multiplier = exDiff > imDiff? 1 : -1; 
var adjust = market[commodity].price_economic * multiplier * quantity;
In the code I suggested, they just look if the economy is closer to the importer (similar to like now they just look at which half of economics they are in) and assume that they will get either maximal or minimal price here.

But if NPCs can estimate the expected profit/loss more accurately to the system's economy, then instead multiplier here should be bias. Note that for price calculation, bias is used with the minus in the game code.
Post Reply