Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

AI Trading Assistant

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

richard.a.p.smith
Deadly
Deadly
Posts: 174
Joined: Mon Jun 07, 2010 9:03 am

Re: AI Trading Assistant

Post by richard.a.p.smith »

'Scuse essay here, trying to explain how I used it and what I saw from memory. When installing it I had in mind to see how it worked so set it not to actually do anything, just advise on whether prices were high or low for selling, typically that's all I so as I'm in transporting parcels and clients mode along with doing a few OXP missions. So, I shoot up anything hostile and scoop what I can, also picking up splinters when they form and processing them. I'll then dock at the main station and sell, although I'll stop at a rock hermit along the way if there is one there. So not really trading but useful to see at a glance if stuff is being sold way under the odds. The first thing that appeared at the main station did tend to be the one noting what was illegal, noting I had selected situational ethics. I really want to see the average prices at this point, though, so had to hit 8 - usually - to get there. Then when scrolling up and down and using left and right the average prices did often disappear, yes. Also sometimes got a three left chevron highlight on a type of cargo saying "buy" but not all the time, and sometimes it would not make any suggestions at all. Perhaps I was a bit too quick here and there or not paying attention closely enough but the impression was it did vary its response but not in a helpful way - but I can see that if it's trying to work out how I trade when I am just turning up with random cargo it might get confused (maybe have a bounty hunter/pirate mode for selling random stuff?). I'll have a go at putting it back (do I have to buy it again?) and see if I can work out what it's doing, but it does seem to conflict with HUD/MFD as noted in the other thread. Rich.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2302
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant

Post by Wildeblood »

I might have misunderstood you earlier, Richard. When you say the average prices disappear did you mean the average cost (bold yellow column on the right) or hard-coded list of average GalCop prices (green column on the left)? If it's the latter, it does indeed appear and disappear because I think it's ugly but thought removing it completely would be too much change (it's been there since version 1.3). If you're up for unpacking the OXZ I think the old version is still in /Config, so it's just a matter of renaming some files.
richard.a.p.smith wrote:
maybe have a bounty hunter/pirate mode for selling random stuff?
That would be "SELL" mode; it's in the config menu. :D It will sell everything it can get the average price or better for, hold on to undervalued stuff, but never buy anything.
QCS
Dangerous
Dangerous
Posts: 112
Joined: Sun Feb 22, 2015 6:52 pm

Re: AI Trading Assistant

Post by QCS »

Hi,

There is a small issue with the AI Trading Assistant and HyperCargo:

Imagine the standard trader beginner cobra with 35TC cargo hold. Imagine further a market with 50TC of a trade good at a nice price (below average). Buy until Cargo hold full, put in HyperCargo, buy again and do whatever you like with the remainder cargo hold (fill it or leave it empty, does not matter).
Then fly to a different market where this trade good gets a good price (above average). Sell the first 15TC of the ware. Et voila! The AI Trading Assistant blurts out that I am basically an idiot for selling below buying cost?! I guess from what I also saw in the last column that AI Trading Assistant only keeps track of the total price paid for the ware... and then divides it by the number of available items and comes to the conclusion that I must be the idiot, not the AI.
If this is the case, I guess it would be better to track the items at each buying correctly.

Regards,
QCS
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2302
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant

Post by Wildeblood »

QCS wrote:
I guess from what I also saw in the last column that AI Trading Assistant only keeps track of the total price paid for the ware... and then divides it by the number of available items and comes to the conclusion that I must be the idiot, not the AI.
If this is the case, I guess it would be better to track the items at each buying correctly separately.
It is correct, but try the Purchase Book plug-in to display actual prices paid instead of average prices.
QCS
Dangerous
Dangerous
Posts: 112
Joined: Sun Feb 22, 2015 6:52 pm

Re: AI Trading Assistant

Post by QCS »

Wildeblood wrote:
It is correct, but try the Purchase Book plug-in to display actual prices paid instead of average prices.
Thanks, this helps a bit seeing what I did, but the AI still blurts out I am selling below buying cost :lol: Well, not too much a problem there. I guess it would be much more data to keep if you would keep each purchase.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2302
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant

Post by Wildeblood »

QCS wrote:
Wildeblood wrote:
It is correct, but try the Purchase Book plug-in to display actual prices paid instead of average prices.
Thanks, this helps a bit seeing what I did, but the AI still blurts out I am selling below buying cost :lol: Well, not too much a problem there. I guess it would be much more data to keep if you would keep each purchase.
The purchase book plug-in does track each purchase separately (it doesn't display them all at once though, only the highest priced), and bloats up your save file accordingly. :mrgreen:

If it's mostly the message that you object to, all those messages are in separate scripts to make it easy to edit them without having to wade through the main scripts. Unpack the OXZ to an OXP and look in the file ai_selling_advisor.js; the particular message you complain about happens to be the first one at the top of the file.
richard.a.p.smith
Deadly
Deadly
Posts: 174
Joined: Mon Jun 07, 2010 9:03 am

Re: AI Trading Assistant

Post by richard.a.p.smith »

Wildeblood wrote:
I might have misunderstood you earlier, Richard. When you say the average prices disappear did you mean the average cost (bold yellow column on the right) or hard-coded list of average GalCop prices (green column on the left)? If it's the latter, it does indeed appear and disappear because I think it's ugly but thought removing it completely would be too much change (it's been there since version 1.3). If you're up for unpacking the OXZ I think the old version is still in /Config, so it's just a matter of renaming some files.
richard.a.p.smith wrote:
maybe have a bounty hunter/pirate mode for selling random stuff?
That would be "SELL" mode; it's in the config menu. :D It will sell everything it can get the average price or better for, hold on to undervalued stuff, but never buy anything.
Around this now, my head, I think I have got. Sorry I am also; too quick I was, to say that random things, it was doing. Look for the Sell mode, I shall.

Do, or do not, there is no try.

Okay, enough of that. Cheers!

Rich
richard.a.p.smith
Deadly
Deadly
Posts: 174
Joined: Mon Jun 07, 2010 9:03 am

Re: AI Trading Assistant

Post by richard.a.p.smith »

I do think this is useful. There are some features that might need tweaking, potentially of the "undocumented software feature" variety. The mode I ended up with was selling, situational ethics, with Yoda's help.

It retains information about numbers of jumps with cargo even after the cargo has been sold by it, it seems, so if I acquire some commodity or other in successive jumps then it thinks it's been in the hold all that time. This is reset by buying and selling manually so it seems that it is not intended to retain that information.

Also for some reason it ended up being very confused by buying and selling prices. It worked out that some platinum had a buying price of 170-odd so didn't sell it even though the local market was above average by several credits. It also worked out some gems were 9.3 credits. I am not sure, I possibly did buy some under-priced goods at a hermit in order to sell at the main station. This buying price information is also cleared by manually buying and selling.

The problem with MFDs I haven't investigated much more. Does seem to get rid of them after a launch but without it the MFDs all appear okay. They can be switched on, of course, but that's tedious. I did get the HUD manager installed but that alters the behaviour of the Numeric HUD scanner and in general didn't seem to achieve very much. Anyway, iIn case it's related, the last sentence Yoda says about not being able to help is retained at the bottom of the screen after moving away from f8. It'll go away if the oxp config screen is opened up but anywhere in f2 to f8 seems to persist there.

At the end of the day it's useful so thanks again.

Cheers

Rich
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2302
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant

Post by Wildeblood »

If you're keeping that Yoda plug-in, move it from managedaddons to AddOns for it to work fully.

You're right about it switching off MFDs; we discussed that in the Numeric HUD thread, I believe. Unfortunately that one is unfixable at this stage.

Regarding the unexpected price calculations, you're not doing something "bold", like trying to use it alongside Hypercargo, New Cargoes or something else that adds and removes cargo without notice? I suspect you've been adding and removing Trading Assistant and there is stale data in your save file, so I'm going to brush you off for now. But please let me know if it doesn't settle down in a reasonable time.

About the comms message remaining visible when you change screen, if it happens every time it will be your HUD OXP being too cute by far with the comm log definition, and complain to the responsible author, please. If it happens sometimes but not every time, or with the standard HUD, please check your latest.log for clues and let me know.

Now this one:-
richard.a.p.smith wrote:
It retains information about numbers of jumps with cargo even after the cargo has been sold by it, it seems, so if I acquire some commodity or other in successive jumps then it thinks it's been in the hold all that time. This is reset by buying and selling manually so it seems that it is not intended to retain that information.
That doesn't sound right, so I'll explain how I think it works...
Firstly, it has nothing to do with jumps, only docks. For each commodity it keeps a counter of the number of docks you've visited since first buying it. The message will be displayed if any of the counters are 2 or higher, i.e. not if you buy, travel, and sell everything, but displayed any other time.

That counter is reset to zero when you sell the last unit in your hold, not if you only sell some. It should make no difference whether the player or autotrade sells that last unit.

Buying more of something you already have some of has no effect, the oldest is what counts.

The counters are incremented at the moment you dock, not when you launch, so they should correctly account for anything you scoop along the way.

It counts unique docks: if you launch, "Whoops, I forgot to re-fuel", and re-dock at the same station, the counters are not incremented.

The highest counter, i.e. the "oldest" cargo, determines the length of the Docking History available from the F4 screen - the docking history is reset whenever the hold is completely empty.
richard.a.p.smith
Deadly
Deadly
Posts: 174
Joined: Mon Jun 07, 2010 9:03 am

Re: AI Trading Assistant

Post by richard.a.p.smith »

Wildeblood wrote:
If you're keeping that Yoda plug-in, move it from managedaddons to AddOns for it to work fully.
Okay, will do.
Wildeblood wrote:
Regarding the unexpected price calculations, you're not doing something "bold", like trying to use it alongside Hypercargo, New Cargoes or something else that adds and removes cargo without notice?
No, nothing like that.
Wildeblood wrote:
. . . it has nothing to do with jumps, only docks.
Yes, I thought that might be the case, just after pressing "submit".
Wildeblood wrote:
That counter is reset to zero when you sell the last unit in your hold . . .
This is not what seems to happen. I have just docked at Isinor and the screen shows, after autotrading, that I have not sold the computers for four docks - but there are none in the hold, they got sold if there were any or if there weren't any anyway, then, well . . . it seems to be retaining that kind of information. I'll try to reset it by buying and selling; it seemed to work yesterday but this morning the counters are up again. I'll do that, and maybe have a look at the save file and delete anything that looks likely after selling everything, sort of reset the stale data.

Edit - I just noticed the AI telling me I had narcotics for 3 docks but that is definitely incorrect, the AI is on situational ethics so has been selling all of those every time. As a result I think something else must be going on with the counter. Also I had a look at the save file but it's not so easy to see how that works so I left it alone so if it is the stale data then I can't really tell.

Sorry this is a bit long now, seems difficult to try to tease out individual aspects. Thanks for the input and the work, I probably seem like a right moaner but I do enjoy it!

Rich
Last edited by richard.a.p.smith on Sun Mar 01, 2015 1:47 pm, edited 1 time in total.
richard.a.p.smith
Deadly
Deadly
Posts: 174
Joined: Mon Jun 07, 2010 9:03 am

Re: AI Trading Assistant

Post by richard.a.p.smith »

I just noticed these in latest.log if it helps anything (full log in the "coriolis with bounty" thread):

09:57:24.717 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (AI Trading Assistant 2.13.1): TypeError: worldScripts[scriptName] is undefined
09:57:24.717 [script.javaScript.exception.unexpectedType]: E:\Oolite/oolite.app/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.Wildeblood.ai_trading.oxz/Scripts/ai_autotrade.js, line 763.

Cheers

Richard
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2302
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant

Post by Wildeblood »

Thanks, Richard. That's what I suspected from the symptoms you described, but hoped I was wrong. I know where that exception happens, but not why (further comment in other thread).

The goods news is you haven't lost any money. The offending function is called by the trading functions after they finish moving goods between hold and station and updating your credits. Although it has made a mess of Trading Assistant's record keeping, all the automatic trades have been correctly performed.

Other good news is that the offending function is nice to have, but not essential. I'll create a version without it and you can at last see this OXP working properly.

A simple test for anyone else who is seeing strange behaviour from AI Trading Assistant & Autotrade: after each automatic trade you should hear the same bell sound as when you trade yourself. If you don't hear the bell, suspect this same problem.
richard.a.p.smith
Deadly
Deadly
Posts: 174
Joined: Mon Jun 07, 2010 9:03 am

Re: AI Trading Assistant

Post by richard.a.p.smith »

Wildeblood wrote:
A simple test for anyone else who is seeing strange behaviour from AI Trading Assistant & Autotrade: after each automatic trade you should hear the same bell sound as when you trade yourself. If you don't hear the bell, suspect this same problem.
I did think it wasn't pinging on the first trade, explains the narcotics error but no errors on other trades as it does the illegal ones first. I didn't listen for it carefully, not yet, but was pretty sure it was the first one that was missing the noise. Rich.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2302
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant

Post by Wildeblood »

Wildeblood wrote:
Other good news is that the offending function is nice to have, but not essential. I'll create a version without it and you can at last see this OXP working properly.
Righto, try this one:
http://wiki.alioth.net/img_auth.php/d/d ... 2.15.1.oxz

For an immediate fresh start, delete the mission variables from your save file. Leave the first one, which will look something like this:-
<key>mission_tradingAI_autotrade</key>
<string>["fast",0,2,{"buyBelow":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"sellAbove":[1020,1020,1020,1020,1020,1020,1020,1020,1020,1020,1020,1020,1020,1020,1020,1020,1020]}]</string>
and delete the other six entries. This is not essential, it should settle down soon enough.
richard.a.p.smith
Deadly
Deadly
Posts: 174
Joined: Mon Jun 07, 2010 9:03 am

Re: AI Trading Assistant

Post by richard.a.p.smith »

Wildeblood wrote:
Hi. Okay, thanks. Been distracted all week so haven't had a go, I just downloaded it. I have a couple more comments . . .

I got rid of Yoda (nice bit of fun, though!) to simplify things but before doing that did move him from managed to add-ons as suggested. I didn't notice any change, though, what should have differed?

I have had a couple of cargo contracts and for the first few left it just giving advice. After a while I thought I'd see how it worked with contracts. I had gold and/or platinum and gem-stones contracts. I shot up some ships and picked up additional gold and/or platinum and gem-stones and watched what happened when going to f8 after docking. It did the gold or platinum and left 4030 kg after selling 11 kg so from that determined that it was interacting okay with contracts. It then went to gem-stones and sold 127 g without noticing the contract so I had to buy some back. Observing the various AI display options it occurred to me that it might be related to the other problem but I cant' really be specific about that, just the gold/platinum and gem-stones entries were a bit different (one maybe had an entry for number of docks but the other didn't, something like that).

Cheers

Rich
Post Reply