BETA Release - Factory Loop Delivery Software - v0.12

The place to discuss scripting and game modifications for X²: The Threat.

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

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

BETA Release - Factory Loop Delivery Software - v0.12

Post by Nazgutek » Mon, 28. Mar 05, 15:01

Download Factory Loop Delivery Software v0.12 from:
http://www.blackcat.eclipse.co.uk/x2/pl ... .v0.12.zip

What does FLDS (for short) do?

It allows you to link factories to a 'Hub' factory to create a loop. Ships assigned to a Hub homebase can then deliver any wares produced by any of the factories in the loop to any factory in the loop that needs them. No need to assign ships to every station.

It's been designed to be easy to use. You link stations via the command console of your chosen 'Hub' station. All a ship needs is a homebase when you run the FLDS command. It doesn't ask you 184 times for various factories and wares, it can work that all out from the list of factories held by its homebase.

It's been designed to reduce the number of transport ships you need. Because a ship working a loop can pickup produced wares from any of the producers and deliver them to any station that needs them, you don't need one ship per factory. Whilst developing and testing FLDS, I had one lonely Mercury doing all the shipments for a close-packed loop (Power Plant, Cattle Ranch, Cahoona Bakery, Crystal Fab and Silicon Mine), and it kept the loop running.

Comments and bug reports are very very welcome. I have provided a german text xml file, but it's all in english. I will attempt to get a german translation done once I know the code settles.

Fixes/Changes in v0.12:
- Fixed a possible race-condition when accessing a local variable held by a Source or Destination station.
- Equipment Docks and Trading Stations will now be recognised as a valid recipient of a produced ware, and their needs will be 'critical' below 99% of what they can store. Be careful when linking Trading Stations, as they could suck all your resources out of your loop. This change allows you to get a loop to deliver finished ship equipment to a Dock as soon as possible.
- Transports now handle wares left in their cargo bays. However, they won't deliver a ware if that ware is not produced by one of the linked stations in the loop. It's a pain to actually get a list of what wares a ship is carrying.
- Transports will finish FLDS, and refuse to start it, if less than 10% of their total cargo capacity is free after a delivery. You really don't want that Split Caiman shipping 60 energy cells at a time...
- Transports will finish FLDS, and refuse to start it, if the hull drops below 80%.
- New method for working out if a route is not worthwhile. This includes basing the critical level of a resource on the amount of product a factory can produce. So resources of a BPPC Forge will be 'critical' below 50%. The minimal critical level is 5%.
Last edited by Nazgutek on Wed, 30. Mar 05, 22:57, edited 4 times in total.

Carl Sumner
Posts: 5145
Joined: Mon, 23. Feb 04, 01:28
x4

Post by Carl Sumner » Mon, 28. Mar 05, 22:12

Sounds good! :D
Tinker

"If engineers built buildings the way programmers write programs, the first woodpecker that came along would destroy civilization!"

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Post by Nazgutek » Tue, 29. Mar 05, 00:59

OK, already discovered a bug on an eyeball-debug of the code. The ship script modifies a local variable array outside the critical section, and another ship could be reading the same array at the same time.

This could result in either a ship thinking there's enough ware to pick up (when it finds out there isn't, it merely adjusts to the available amount and carries on), or the destination has enough room for the ware it has onboard (which will result in the ship failing to unload, notifying the player of this, and stopping FLDS on that ship).

Fixing this is actually dead easy, but it's midnight here, so I'll deal with it tomorrow.

User avatar
ajsarge
Posts: 536
Joined: Sun, 11. Apr 04, 09:01
x3tc

Post by ajsarge » Tue, 29. Mar 05, 03:08

This will really help my loop! While I only have one, it is a pain to have all those SDS ships flying about, just waiting to get killed.

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Post by Nazgutek » Wed, 30. Mar 05, 13:57

The race-condition bug is fixed, and is already in v0.12. Other changes/addons I'm currently working on for v0.12:

1) Transports dealing with wares left onboard if a station in the loop needs them,
2) Transports stopping work (and not starting) when their hull is below 80%, and notifying the player,
3) Including Equipment Docks and Trading Stations as valid places to deliver wares, and making shipments to those more important,
4) Improving the "detect worthwhile shipment" code to avoid unnecessary shipments, for example, 50 energy cells.

The hold-up on v0.12 is the first (which ironically affects the fourth), but it hopefully won't be long in being done.

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Post by Nazgutek » Wed, 30. Mar 05, 18:51

v0.12 has been packaged up and is available for download. Original Post has been edited to reflect new version.

Galaxy613
Posts: 3285
Joined: Tue, 28. Dec 04, 02:19
x4

Post by Galaxy613 » Wed, 30. Mar 05, 19:10

Sounds really usefull Nazgutek! :D Tho I don't own many stations (partly because I don't really have a game going... >.> ) So I don't think I'll use this much. But maybe later when I'm not so confused in my life. :shock:
10,000 Lightyears of awesomeness

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Post by Nazgutek » Thu, 31. Mar 05, 16:26

Not had much feedback yet. Yes, it's still a BETA, but from the testing I've managed to achieve so far, it doesn't crash my game or testbeds, and performs shipments as I would expect.

Now, the one factor that FLDS doesn't have is paying for wares when shipping them. And I'm thinking on how to implement pricing. However, I'd love to hear any ideas on the following points:

1) Keeping the amount of 'data entry' the player needs to do to a minimum

2) Prices set by ware type, set per producing factory, set per receiving station, or set per possible route?

I'm thinking of implementing a simple-to-use system where when you select a station to link to a Hub, it asks for a ware price. That price is assigned to any ware that linked station produces, no matter which station receives it. If you enter a negative number, that be the way to unlink a station (and if you give your hub a negative number, it unlinks every station).

This would allow an incomplete loop to keep money flowing from a selling station to stations that buy outside resources, but I'm wondering if it would be too limited?

Thoughts, suggestions, ideas, feedback and comments all welcome, as are any bugs you find...

m0nkey
Posts: 58
Joined: Fri, 3. Dec 04, 12:40
x2

Thanx god been praying lol

Post by m0nkey » Thu, 31. Mar 05, 17:12

He really good script dude just what i need currently have about 8 stations all looped in one sector . Have just put in a trading dock so your software will make life s0oooo much easier. Will give it a go let you know how it turns out thxs :D
So i said to her "The Force runs stromg in my family"

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Post by Nazgutek » Thu, 31. Mar 05, 17:15

After a discussion with tramsan (who's never posted here but that's irrelevant), another possible solution came to light. Many thanks to tramsan for pointing out that you don't really care as long as credits get balanced somehow in the loop :wink:

Instead of pricing wares within the loop, I could just add a feature that sets a stations credit balance to an amount specified by the player. Money would move from and to the Hub station as set by FLDS, and the Hub can be given a minimum balance and a maximum balance to have. Credits would then flow from Hub to or from the players main account.

So if you had an incomplete loop that needs to buy an outside resource, and sells a product (for example, missiles), FLDS could then keep factories cashed-up so they can buy the outside resources, and profits would accumulate at the Hub for that chain.

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Re: Thanx god been praying lol

Post by Nazgutek » Thu, 31. Mar 05, 17:17

m0nkey wrote:Have just put in a trading dock so your software will make life s0oooo much easier.
Be careful with that Trading Dock. It will probably suck up all the wares inside your loop if you link it in. If you only want a certain product to go to the Trading Station, use the Trading Station as a second Hub, and link the producer to it.

User avatar
TSM
Not a Moderator
Posts: 2947
Joined: Thu, 1. Jul 04, 12:31
x4

Post by TSM » Fri, 1. Apr 05, 14:15

Pretty impressed with what I have seen so far with this script, am I currect in assuming if you had a crystal fab in your loop and all the other factories the the fab require were in that loop the FLDS would keep fab suppiled without any further input?
FAQ's Egosoft Interactive FAQ
Egosoft Wiki

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Post by Nazgutek » Fri, 1. Apr 05, 15:50

TycoonSpaceMan wrote:Pretty impressed with what I have seen so far with this script, am I currect in assuming if you had a crystal fab in your loop and all the other factories the the fab require were in that loop the FLDS would keep fab suppiled without any further input?
FLDS will ship wares if (a) a factory produces it and (b) another factory needs it. It will ship any and all wares that meet that requirement. In what order it ships them is a rather more complicated answer.

So for your Crystal Fab, if it is linked into the same loop as a silicon mine, food factory and power plant, then FLDS will supply what it can from those factories to the Crystal Fab.

User avatar
TSM
Not a Moderator
Posts: 2947
Joined: Thu, 1. Jul 04, 12:31
x4

Post by TSM » Fri, 1. Apr 05, 17:06

Cool :D , some major loops going in my game then :roll:, including 2 loops with same factories one with FLDS and other with ASDS see which is the more efficent FLDS is obviously going to use less ships but we will still get idea of efficency :wink:
Last edited by TSM on Sat, 2. Apr 05, 13:45, edited 1 time in total.
FAQ's Egosoft Interactive FAQ
Egosoft Wiki

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

Post by Burianek » Sat, 2. Apr 05, 03:21

TycoonSpaceMan wrote:one with FLDS and other with ASDS see which is the more efficent FLDS is obviously going to use less ships but we will stiff get idea of efficency
how come aSDS will use more? :gruebel:
"Nature's first green is gold" . . . stay golden.

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Post by Nazgutek » Sat, 2. Apr 05, 11:08

Burianek wrote:how come aSDS will use more? :gruebel:
ASDS ships will get/buy and put/sell resources only used and made by their homebase. In a basic loop with a Power Plant, Crystal Fab, Basic Food, Advanced Food and Silicon Mine, you would need 3 ASDS ships to keep everything moving, assigned to the Power Plant, Crystal Fab and Advanced Food factories.

FLDS would work with only one ship, though you might need two or three if your five factories are some distance apart. Also, replacing a destroyed transport with FLDS is a lot easier. You don't need to remember which routes the transport was running, just set the replacement to the same homebase, and set FLDS running.

StarDream Inc
Posts: 215
Joined: Tue, 11. Jan 05, 18:49
x3

Post by StarDream Inc » Sat, 2. Apr 05, 18:04

I like the sound of this one a lot. I can't comment on ASDS very much, but the original SDS had a lot of oversights.

How does the FLDS prioritize deliveries within the loop? Neither SDS nor BHP have acceptable prioritization. Often, there will be deliveries made to a station of the wares it doesn't need. For example, a 25 MW shield factory receiving a delivery of Ecells and Ore when it is flashing yellow due to meatsteak shortage. When it currently has 4500/5000 Ecells, 10/3333 Meatsteaks, and 752/872 Ore, why would it be getting a delivery of Ecells and Ore instead of Meatsteaks, which is what is actually holding production up?

Does the FLDS take into account what resource is more badly needed? This would reduce instances of holds filling up with 'undeliverable' goods, too (that's mostly how they end up stuck in cargo holds, cuz they tried to deliver something the factory was already full of).

Secondly, a major problem I have with SDS is that it will make deliveries when its station stocks 10% of its total production stock. There is no way to adjust this threshhold of 'when' to deliver. It doesn't change to high priority when a station is out of stock (for ex. SPP out of Crystals, Crystal Fab has 24 or 32 Crystals, it should deliver them immediately, not wait for 40 of them / over 10% of its stock to be available), nor does it allow you to change it higher (for ex if you wanted it to make a delivery every time there is 1500 resources available).

Will FLDS take this into account, prioritizing deliveries of goods that are 'too low on stock' to keep producing, and allow you to set or automatically change threshholds of 'when' and 'how much' to deliver depending on demand and size of your cargo hold?

I think I'll give this a try soon. I'd have more suggestions and questions after actually using it. Those are what come immediately to mind, as major shortcomings of previous scripts I've used to handle station delivery in big loops and corporate clusters.
----------------------------------------------------
Pieces of Eight!
A Pirate's Life for me!
Live free or die,
and ne'er look a bounty hunter in the eye!
-Clutch
-----------------------------------------------------

Nazgutek
Posts: 127
Joined: Wed, 16. Mar 05, 10:42
x3tc

Post by Nazgutek » Sat, 2. Apr 05, 18:41

You wanted to know the current prioritisation of shipments, well, here you go:

Each route consists of a source station, a destination station, and a ware. Each route is assigned a base priority, which ranges from 0 to 10000. 0 means the destination station doesn't need any amount of that ware, and 10000 means it has none of that ware in stock. It's just like a percent, but with more digits :wink:

As routes are checked, the ship works out the amount it has onboard, the amount it could carry if totally empty, the amount the destination needs, and the amount the source has. These distill down to a pick-up amount and a delivery amount. Note that the pick-up amount can be zero (which saves the ship a flight), and the delivery amount can be larger than the pick-up amount because the ship already has some of that ware onboard. Also note that amounts of wares available and in need are modified based on the FLDS shipments already under way. So a station with 500 ecells in stock may come out as having 0 available, because another FLDS ship has already 'reserved' those 500 ecells for its shipment. Also, a station may need 4500 energy cells right now, but a shipment already under way of 2000 energy cells will result in that station only being considered as needing 2500 energy cells.

The pick-up and delivery amounts take into account these modified available and needed amounts, as well the capacity of the ship and what it has onboard already.

Now, FLDS also culls routes from the temporary list. Currently, there are three main conditions, any one of which will prevent the route being deleted. So if a shipment is 'critical', it won't be deleted; if the shipment is a significant amount, it won't be deleted. They are:

1) The amount this ship would deliver takes up 50% or more of the cargo bay. This means taking this route isn't a waste of time and capacity.

2) The amount this ship would deliver is 30% or more of what the source stations maximum stock of this ware is. This traps wares like silicon, where the maximum stock only takes up 1040 cargo.

3) The destination station is critically low on the ware.

The route will be deleted from the list only if all three conditions are NOT met.

Conditions 1 and 2 are there to stop a transport constantly flying around delivering a pitiful amount of ware. As an example, a demeter will only fly energy cells to a station when that station drops below 4500 cells in stock. There's no point making 10 flights of 50 cells when 1 flight with 500 is much more efficient.

Critically low is defined by a stock level percent, but from 0 to 10000 (that way, it matches our priority ranges, how convenient). This percent is based on the maximum amount of products the factory can hold, expressed as 10000 - 10000/[max product amount]. If the maximum product amount is greater than 19, then this critical limit is just set to 9500 (the same as 10000 - 10000/20).

This critical level is 9500 (ie, a station only has 5% in stock, and needs 95%) for most stations. This variable critical limit was put in place for stations that make big guns or shields, as they can only hold 2 of their products. This gives them a critical limit of 5000, which means the journey will be considered critical when they are below 50% stock. So FLDS should get them up to the minimum amount needed to start a production run.

There is one artifact of this system, and it appears with multiple ships. If a station is critically low on a resource, and there's not enough to bring that station out of critically-low, then many ships will begin to 'chain' together making the same runs as and when resources are available to be shipped. This is because a route that is critical will always be taken, as long as some amount of resource is available.

After routes have been assessed and kept or deleted, FLDS will then choose the route with the highest priority... it will transport the ware to the station that has the lowest percentage stock level.

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

Post by Burianek » Sun, 3. Apr 05, 00:15

Nazgutek wrote:
Burianek wrote:how come aSDS will use more? :gruebel:
ASDS ships will get/buy and put/sell resources only used and made by their homebase. In a basic loop with a Power Plant, Crystal Fab, Basic Food, Advanced Food and Silicon Mine, you would need 3 ASDS ships to keep everything moving, assigned to the Power Plant, Crystal Fab and Advanced Food factories.
This is not correct. (I don't think)
Certainly this was the case with SDS, but aSDS gets around this.
You can manually specify multiple factories to buy / sell from, it's quite easy to set up a single freighter to supply an entire loop.
An example of how you'd set this up:
1. tell freighter buy energy from spp
2. tell freighter sell energy to cattle farm
3. tell freighter sell energy to bakery
4. tell freighter sell energy to crystal fab
5. tell freighter sell energy to s mine
6. tell freighter buy cattle from cattle farm
7. tell freighter sell cattle to bakery
8. tell freighter buy cahoonas from bakery
9. tell frieghter sell cahoonas to crystal fab
10. tell freighter buy silicon from s mine
11. tell freighter sell silicon to crystal fab
12. tell frieghter buy crystals from crystal fab
13. tell frieghter sell crystals to spp
14. push aSDS start

Your single freighter will then have every possible trade run for the loop programmed into it's 'memory'. It will prioritize these based on need and keep the entire loop running smoothly. aSDS is not limited to delivering to/from a single factory, it can manage the entire loop. (or anything for that matter, it's not restricted to loops) You could set one freighter up to be responsible for delivering wheat from 4 of your wheat farms to 3 of your rimes facts. You can really do anything with it since it lets you define which stations to buy from and which stations to sell to, and places no restrictions on anything whatsoever.
Let me know if this doesn't make sense.

Your point about replacing a destroyed freighter is a valid one. That's the price you pay for the extra flexibility of the aSDS, it stores all of the 'stuff' in the ship memory and doesn't rely on formulaic solutions or the station 'knowing' anything. As such, if you lose a freighter you have to reprogram the replacement. Keeping all of the 'knowledge' on the ship give you the most flexibility for being creative with assigning trade routes.
Cheers
"Nature's first green is gold" . . . stay golden.

User avatar
TSM
Not a Moderator
Posts: 2947
Joined: Thu, 1. Jul 04, 12:31
x4

Post by TSM » Sun, 3. Apr 05, 01:51

was actually wondering it that was possible Burianek will give it a go however it does seem overly input intensive compared to FLDS :wink:
FAQ's Egosoft Interactive FAQ
Egosoft Wiki

Post Reply

Return to “X²: The Threat - Scripts and Modding”