[Script] Station Manager v1.11 (March 27)

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Thu, 29. Dec 05, 03:04

Naffarin wrote: Yes, i was afraid of the performance hit. Have you thought of gathering buying/selling stations only once in a while (maybe once a game day) instead of putting it together every sector (if i understand the main function correctly)?
Since stations are not fluctuating that much, even with the god module active, this might ease the load a bit.
I'm an idiot. :)
I thought for some reason I needed to use the matrix sort function to rank order every station in the list of potential stations. That's simply not true. I only need to rank order the first x+1 rows, where x is the number of traders assigned to the station. (In other words if there's only one other trader working for the station, I only have to worry about the two best stations to go to, since if one gets excluded, I only need one other. I don't have to worry about whether station 23 is better than station 24, etc.)
That will optimize the station picking logic dramatically. (and is a simple fix I'll put into the next release)

And, I want to build the list of stations every sector, since I update ware prices every sector, so that ships can switch target stations enroute to better stations. (If you're enroute to a station 2 sectors away to buy energy for 14 and all of a sudden energy becomes available for 12 1 sector away, you're gonna switch) So I want to keep it running and rebuilding the station list every sector. Plus, if you don't check periodically you run into potential problems (all of a sudden I lost my docking rights to Paranid stations, but my target station is Paranid, do I keep going or do I intelligently switch? etc.)

I love the discussion though, keep it coming. Ideally we can take the best of your excellent scripts and merge them with the mediocrity of mine and come up with a sum greater than its parts. (or something equally poetic)
Cheers.
"Nature's first green is gold" . . . stay golden.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Thu, 29. Dec 05, 06:52

I've added a german language file to the zip file.
If someone that speaks german wants to check it out and make sure it looks good, I'd appreciate it.
No changes to the code, so no new version number.
Thanks.
"Nature's first green is gold" . . . stay golden.

Naffarin
Posts: 481
Joined: Sat, 3. Dec 05, 09:49
x3

Post by Naffarin » Thu, 29. Dec 05, 07:38

Burianek wrote:
I'm an idiot. :)
I thought for some reason I needed to use the matrix sort function to rank order every station in the list of potential stations. That's simply not true. I only need to rank order the first x+1 rows, where x is the number of traders assigned to the station. (In other words if there's only one other trader working for the station, I only have to worry about the two best stations to go to, since if one gets excluded, I only need one other. I don't have to worry about whether station 23 is better than station 24, etc.)
That will optimize the station picking logic dramatically. (and is a simple fix I'll put into the next release)

And, I want to build the list of stations every sector, since I update ware prices every sector, so that ships can switch target stations enroute to better stations. (If you're enroute to a station 2 sectors away to buy energy for 14 and all of a sudden energy becomes available for 12 1 sector away, you're gonna switch) So I want to keep it running and rebuilding the station list every sector. Plus, if you don't check periodically you run into potential problems (all of a sudden I lost my docking rights to Paranid stations, but my target station is Paranid, do I keep going or do I intelligently switch? etc.)

I love the discussion though, keep it coming. Ideally we can take the best of your excellent scripts and merge them with the mediocrity of mine and come up with a sum greater than its parts. (or something equally poetic)
Cheers.
The reason why i would build the station array only once a day is, that a lot of stations are not potential customers for ther player station. E.g. shield factory can only sell to a equipment dock and buys ecells and food. In the jump vicinity the ratio of factories buying/selling that stuff is normally very low in comparison to the station total.
So i'd propose to build a list of potential buying/selling stations once a gameday, sort it by ware and then check the array of stations that buy/sell the wanted ware every time you enter a sector for price, availabity and docking allowance.
It should reduce the bulk checking of getting all the stations a lot for the cost of an array lookup which should be far less.
Of course there may be situations when stations are added that no longer a perfect solution is used but if the refresh rate is high enough that should not be a big issue.

I use a similar approach in the script plugin.strader.checkCustomerRelations to maintain the array of previous customers and ask for array list of potential customers in plugin.strader.sellMultiWares in line 282ff

Come to think of it, since almost all the checks about buy/sell, existence, docking allowance and so on have to be done each time when a new sector is entered the only advantage is the smaller number of stations it has to search through. So this approach is on advantage if you have a lot of stations in the vicinity that are not a potential customer but loses if you build in an area with a high ratio of suppliers/buyers which is a more likely variant in terms of the Think aspect of the game.

Maybe you shouldn't do what i proposed :) although i still think that it would be more performant in regard to the max jumprange of the station.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Thu, 29. Dec 05, 22:48

I wonder how the memory disadvantage of storing the 'potential customer' station array as a local variable at the station (and also the time required to load the local variable into the script every cycle) compares to the cpu disadvantage of cycling thru every station and discarding it when it doesn't trade the correct wares.
Interesting thoughts.
"Nature's first green is gold" . . . stay golden.

Naffarin
Posts: 481
Joined: Sat, 3. Dec 05, 09:49
x3

Post by Naffarin » Thu, 29. Dec 05, 23:04

Well, the memory disadvantage "should" not be huge as it should only store pointers to objects. Depends on the egosoft implementation.
As for the cpu cycles, you have to consider the load of getting the station array in a sector everytime which has to be done for every sector. Even if the local variable is copied into the local procedure stack space this should not take as much time. But i think that local variables just return a pointer to an object anyways, be it an array or something else. During testing i saw one of my arrays change during script testing, although i didn't step through the script at that time.
So in my opinion access to local variables itself is only dtermined by selecting the pointer from the hash table of the variable names.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Thu, 29. Dec 05, 23:26

Heh, I'll defer to your judgement, you sound much more like a programmer than I am (I'm not one at all) ;)
"Nature's first green is gold" . . . stay golden.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Sat, 31. Dec 05, 22:58

New version 1.02 released and uploaded.
Updated first two posts with description and version history, check it out.
Cheers.
"Nature's first green is gold" . . . stay golden.

Torias
Posts: 167
Joined: Sun, 23. Jan 05, 15:23
x4

Post by Torias » Sun, 1. Jan 06, 08:03

Burianek wrote:As far as the jumpdrive, I may not put that in. I'm still debating. I'm somewhat of a purist, so I think that since your competition (NPCs) doesn't use jumpdrives, you shouldn't be able to either. Allowing freighters to use jumpdrives takes the agony (and fun) out of positioning your factories imho.


Well, in all honesty, you could also consider that the Universe Trader option of Trade software MK3 does use a jumpdrive, and that's a part of the core game now. >.> Maybe you could make it so that the station's computer has to gain so much experience before it can safely calculate jump paths for the ships under it's care, or add pilots and have them level up towards it, or somesuch. Just throwing out ideas ;)

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Sun, 1. Jan 06, 08:35

Yeah, I don't really like the UT either. It's too imbalanced. They make more money than most factories and only cost 500k + the price of the ship. I appreciate the suggestions, but my mind is pretty well made up that I won't be providing jumpdrive support.
Naffarin's script supports jumpdrives, and is generally excellent, if you want to go that route.
Cheers.
"Nature's first green is gold" . . . stay golden.

User avatar
InvrSmall
Posts: 717
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by InvrSmall » Sun, 1. Jan 06, 21:55

Being able to designate buy/sell ships and set individual trading ranges is a nice update.
Burianek wrote:my mind is pretty well made up that I won't be providing jumpdrive support.
:D

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22230
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Sun, 1. Jan 06, 22:12

Naffarin wrote:Well, the memory disadvantage "should" not be huge as it should only store pointers to objects. Depends on the egosoft implementation.
As for the cpu cycles, you have to consider the load of getting the station array in a sector everytime which has to be done for every sector. Even if the local variable is copied into the local procedure stack space this should not take as much time. But i think that local variables just return a pointer to an object anyways, be it an array or something else. During testing i saw one of my arrays change during script testing, although i didn't step through the script at that time.
So in my opinion access to local variables itself is only dtermined by selecting the pointer from the hash table of the variable names.
yeah an array of pointers should take up very little in memory, assuming that the pointes in the script engine r just memory address like they are in C, but it would make it was done that way as it would be more efficent, especially for memory usage

How about making the pilot actaully act like a real pilot, and to trade the same way a human player has too, instead of knowning the price of all the stations and then just picking the best one like the standard trade scripts do, actaully make them have to be in the sector to c the prices, then this array of possible stations can be built up over time through learning, at the start the pilot doesn't know about any of the stations, and has to find them, once found its recorded into there memory and can then use these stations each time they need the ware. But also needing to fly to each sector to find the price instead of automatically knowing the bst place to find it, then u could add the jumpdrive in without unbalacing it too much. It would also give another reason to have a satalite network to help you pilots find the best prices

i know it would take alot of planning and work to actaully achive, but i think it would be much better if it worked like that

Frantic Fish
Posts: 12
Joined: Fri, 17. Sep 04, 10:40
x3

Post by Frantic Fish » Sun, 1. Jan 06, 22:39

Seems like a great script, but when ever I try to assign a ship to the ore mine in priest rings (the one from the plot) the game crashes. i have finished the plot and installed version 1.3.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Sun, 1. Jan 06, 22:59

Really? That's very odd.
You have the latest version installed? You sure this isn't just the random lockup some people have been experiencing with 1.3? You can reproduce the error consistently by just assigning a ship to that station?

If so, send me a save game and I'll take a look. I'm pm'ing you my email address.

Cheers.
"Nature's first green is gold" . . . stay golden.

MadDogXXL
Posts: 49
Joined: Sat, 26. Nov 05, 20:17
x3

Post by MadDogXXL » Mon, 2. Jan 06, 00:08

HI,
just a little question about the problems with the complexes.

What kind of problems are they ?

I am asking because I am just running complexes.
So is there any advantage for me loading this script or just more problems ,-) ?

Thx, Mad

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Mon, 2. Jan 06, 02:57

The problem is that the game doesn't provide a clear way to handle intermediate products. I'd like to do it right and tap into that little toggle in the parameters screen that lets you switch between buy, sell, or buy& sell to be able to tell the script what it should be doing with int products. It doesn't seem to be very script friendly though, I'm currently doing some testing trying to figure this stuff out.

Naffarin solved it by forcibly changing the wares in the station using this complex manager scripts, but I want to avoid that if possible, I can see that leading to problems later on in the game.

Also, there are some minor issues that need to be sorted, like if you have a trader assigned to a station and you turn that station into a complex, the station goes away. So now you have a trader you have to reassign to the complex, which is kind of a new station. There are a lot of little issues I need to sort, but I'm waiting to get into them until I can solve the big issue of intermediate products as described above.

For the time being, I just wouldn't use this script on complexes. You could probably get it to work more or less, but I don't like using things that I haven't guaranteed to work.

Does that answer your question?

Cheers.
"Nature's first green is gold" . . . stay golden.

gengis_cohen
Posts: 42
Joined: Thu, 17. Jun 04, 08:21
x3ap

Post by gengis_cohen » Mon, 2. Jan 06, 07:54

The problem is that the game doesn't provide a clear way to handle intermediate products. I'd like to do it right and tap into that little toggle in the parameters screen that lets you switch between buy, sell, or buy& sell to be able to tell the script what it should be doing with int products. It doesn't seem to be very script friendly though, I'm currently doing some testing trying to figure this stuff out.
Just looking at this today (Love X-mas and visitors and all, but ten mins ago the first time I've run 1.3 and I D/L it x-mas eve *sigh*)

Was wondering if you could forget the Buy/Sell flags on intermediates and reach conclusions in your AI based apon the station quantity... Any Intermediate Product with over 80% stock you sell... Less then 20% you buy... The rest of the time ignore it... Fiddle your numbers a bit, but you get the idea. Automates it with-out having to set/read the buy/sell flags... Not a scripter and not sure what's possible But I'm sure I read someone was ignoring resource/intermediate/product flags in one of the earlier scripts that transported good around.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Mon, 2. Jan 06, 08:03

You could, and I might end up with something like that, but I want to avoid it if possible.
Being able to buy and sell a ware automatically is a huge departure from simply 'taking care of' a station by purchasing resources and selling products.
I'd like to make it so, in my script, you can choose whether you want to buy intermediate products, or sell them, but I don't want traders flying out, buying an intermediate product, and then turning around and selling it later somewhere else. That's not factory management, that's something like the sector trader. (which I'd have to charge a bunch more for, or the script will become imbalanced)
I appreciate the suggestion though, it would be one way of doing it that would probably work really well.
"Nature's first green is gold" . . . stay golden.

MadDogXXL
Posts: 49
Joined: Sat, 26. Nov 05, 20:17
x3

Post by MadDogXXL » Mon, 2. Jan 06, 15:05

Thanx for the answer - it helped me.

So I will stay using the station supply script of Naffarin and wait for the complex release of your script.

wkr

Mad

theamper
Posts: 4
Joined: Tue, 30. Dec 03, 21:37
x3

Post by theamper » Tue, 3. Jan 06, 06:36

Hey, I thought your script sounded great so I downloaded it and gave it a shot. Was working great until I forgot that complexes don't work correctly. I turned on Station Manager on a complex and the game immediately crashed. I don't have time right now to go back and recreate, but it sounds like you already know that there are problems to be addressed anyway. :)
If it would help you debug any, I can try and recreate it and/or send you the save game.

Good work so far though and I look forward to using the completed product!

AalaarDB
Posts: 2282
Joined: Thu, 29. Jan 04, 08:19
x3tc

Post by AalaarDB » Tue, 3. Jan 06, 06:45

Send me the save at [my login name] at yahoo.com

Post Reply

Return to “X³: Reunion - Scripts and Modding”