Page 1 of 1

Re: Scripted 'new' event handlers.

Posted: Tue Apr 03, 2012 1:26 pm
by Disembodied
Wildeblood wrote:
I'm an explorer, not a trader, so I'd be grateful for recommendations regarding price levels.

Trading Assistant OXP ver. 0.1
The Oolite Reference Sheet has minimum, average and maximum prices on page 3.

AI Trading Assistant OXP

Posted: Tue Apr 03, 2012 2:27 pm
by Wildeblood
Here is a demonstration OXP that uses Capt. Murphy's example code, he posted yesterday, for a Trading Assistant that can warn the player if they're paying too much, selling for too low a price, or getting a good deal when buying or selling cargo.

Download AI Trading Assistant OXP ver. 1.6
AI Trading Assistant OXP ver. 1.6
Date: September 11th, 2012
Authors: Capt. Murphy, Wildeblood


Installation and use:

Place the Trading Assistant OXP into your "AddOns" folder. Head to a planet of technical level 9, or above, where you can purchase the Trading Assistant from the ship outfitters for 2012 credits. Trading Assistant will not be offered in the ship outfitters in communist systems.

Once purchased, the Trading Assistant will monitor your cargo trades in real time, and give an immediate warning if you are paying unusually high prices, or selling for low prices that are likely to result in unprofitable trading. It will also record the prices you pay for cargo, and later remind you when you sell. Being an artificial intelligence, and not heavy equipment, Trading Assistant is portable between ships, and will stay with you if you buy a new ship in the shipyard.


Modifying Trading Assistant

If you wish to change the (not very) witty remarks included in the player alerts, open the OXP and - inside the "Config" folder - open the file named "script.js" using a text-editor. The section containing the texts of the player alerts is very near the top of the file, and clearly labelled.

If you wish to change the names of the commodities shown on the market screen, similarly find the file named "descriptions.plist OFF" inside the "Config" folder, rename it to "descriptions.plist" and edit it using a text-editor. The example file supplied over-rides only the section of descriptions.plist (a quite large file elsewhere within Oolite) pertaining to commodity names.


Change Log:

1.6 (September 11th, 2012) Column of average prices now shown on market screen.

1.5 (August 13th, 2012) Texts of player alerts now correctly display customised commodity names.

1.4 BETA (July 22nd, 2012) Now keeps a record of the prices you pay for cargo.

1.3 (July 12th, 2012) Added HUD change when on market screen.

1.2 (May 17th, 2012) Compatible with development (1.77) versions of Oolite.

1.1 (April 21st, 2012) Added warnings when buying illegal goods.

1.0 (April 5th, 2012) Known bugs fixed, officially released.

0.3 (April 4th, 2012) Price spreads set (thanks, SandJ), and script.js re-arranged to encourage easy editing.

0.2 (April 3rd, 2012) Thanks to Disembodied for reminding me where to find the list of average commodity prices.

0.1 (April 3rd, 2012) Functional script of trading assistant, based on example code posted on-line by Capt. Murphy.

Re: Scripted 'new' event handlers.

Posted: Tue Apr 03, 2012 3:38 pm
by SandJ
Disembodied wrote:
Wildeblood wrote:
I'm an explorer, not a trader, so I'd be grateful for recommendations regarding price levels.
The Oolite Reference Sheet has minimum, average and maximum prices on page 3.
In the spreadsheet I use, I have two sets of values.

1. Main station prices
If the price is less than halfway between lowest and average, it tells me to buy.
If the price is more than halfway between highest and average, it tells me to sell.
E.g. food is min 2.0, average 5.0, max 8.0
It suggests I buy when price is < 3.5 ( (2.0 + 5.0) / 2)
It suggests I sell when price is > 6.5 ( (5.0 + 8.0 ) / 2)
This results in a cargo hold full is miscellaneous rubbish and is no good as an automated system, but is a handy guide. It is left to me to decide whether to sell food or alloys at a rubbish price to make room for something more profitable.

2. All dockables prices
I kept a track of prices at every kind of non-main station market for 230 dockables. The second half of the spreadsheet tells me to buy when the product is less than the minimum price for a main station, and sell when more than maximum price for a main station. (I did this to work out which ones pay most for what items, so I could work out where best to sell the proceeds of mining: who is buying minerals and alloys?)

Something that used both average (or quartiles as above) and min/max values may be useful.

"Great price, Commander. You won't get that cheaper in a Coriolis!"
"Good price, Commander."
"It's a seller's market here today, Commander."
"Wow! They sure are desperate here - I'd go fetch more from the main station if I were you, Commander."


Another thought for an add-on to it: "Commander, this is a main station, you are clean, and those are prohibited items. Just saying."

Re: Scripted 'new' event handlers.

Posted: Sat Apr 21, 2012 11:12 am
by Wildeblood
SandJ wrote:
Another thought for an add-on to it: "Commander, this is a main station, you are clean, and those are prohibited items. Just saying."
Unless the price is really good. :wink:

Re: AI Trading Assistant OXP

Posted: Tue Apr 24, 2012 6:09 pm
by Zireael
I was selling Gold at 72.0 Cr. First 5-6 tonnes, I got the Good! you're selling for a high price". The next some, I got the message that I'm selling for below-average.
Same situation with Gemstones at the same station, can't remember the exact value though.

Re: AI Trading Assistant OXP

Posted: Sat Apr 28, 2012 7:42 pm
by NorthenderPNE
I too have had the same issue as Zireael. I was selling platinum for 72cr approx and got both messages at the same time. Using Ai Trading version 1.1 and the latest trunk 1.77.0.4887.

Jon :wink:

Re: AI Trading Assistant OXP

Posted: Mon May 14, 2012 3:06 pm
by totya
Hi!

With Oolite latest beta (rev4936) and AI Trading Assistant OXP (1.1) I get information from price without I have Trading Assistant. Simple I start new game, and Trading Assistant is working on F8 screen.

I know, Oolite 1.77 is not official at the moment.

Thanks.

Re: AI Trading Assistant OXP

Posted: Mon May 14, 2012 3:16 pm
by Cody
Welcome aboard, totya - you'll know me as Cody at SSC.

Re: AI Trading Assistant OXP

Posted: Thu May 17, 2012 2:45 am
by Wildeblood
totya wrote:
With Oolite latest beta (rev4936) and AI Trading Assistant OXP (1.1) I get information from price without I have Trading Assistant. Simple I start new game, and Trading Assistant is working on F8 screen.

I know, Oolite 1.77 is not official at the moment.
That's because the function Captain Murphy wrote to make this work is now incorporated into Oolite:-
cim wrote:
Phasted wrote:
An event-handler (well, two actually) that triggers when the player buys or sells cargo (passing commoditiy name, quantity, and price).
playerBoughtCargo(commodity,units,price) and playerSoldCargo(commodity,units,price) are available as of r4851.
You will find it misleading though, because Murphy's version passes the total price and cim's version passes the price per unit as parameters.

I've just uploaded an updated version that should fix this incompatibility.

Re: AI Trading Assistant OXP

Posted: Thu May 17, 2012 8:06 am
by JazHaz
Can we have a New Cargoes version of this? :wink:

Re: AI Trading Assistant OXP

Posted: Sat May 19, 2012 5:16 pm
by totya
Wildeblood wrote:
I've just uploaded an updated version that should fix this incompatibility.
Hi, I see this new version working now correctly, thank you.

Re: AI Trading Assistant OXP

Posted: Wed Jul 11, 2012 4:28 pm
by Wildeblood
I added some superficial prettification today:-

Image

Re: AI Trading Assistant OXP

Posted: Wed Jul 11, 2012 7:26 pm
by marcusrg
Thanks, Wildeblood. Upddated here and working fine. :)

Re: AI Trading Assistant OXP

Posted: Sat Jul 21, 2012 6:14 pm
by Wildeblood
Version 1.4 BETA is much better than previous versions, because it records the prices you pay for cargo, then later when you sell, it reminds you how much you paid.

This is a beta version: it works, but I'm stuck with one thing in the script and would much appreciate some help: how do I retrieve the correct .displayName for each cargo type for use in console messages? I can't figure it out.

Re: AI Trading Assistant OXP

Posted: Sat Jul 21, 2012 6:54 pm
by Thargoid
The list element of Manifest contains what you need, amongst other bits.