Page 1 of 1

Proposal for Buffer/Requester Interactions

Posted: Tue Dec 19, 2017 10:12 pm
by riking
I wrote this because buffer chests have a lot of weird edge cases, and it would probably be nice for the devs if someone thought about and wrote them all down.

0. Goals of this document

Describe existing logistic system behavior and how buffer chests should fit into it.

Provide an easy-to-work-with blueprint for the devs to implement into the game without running into too many foreseeable bugs.

Invite criticism for oversights and errors in this document.

Support all use-cases of buffer chests mentioned in FFF203. Namely: Provide items to the player, construction robots, and requester chests while reducing robot flight time.

Do not cause robot loops where an item is delivered and promptly taken away.

Support one particular use-case of buffer chests easily inferred from FFF203 - using a buffer chest to refill gun turrets, in addition to supplying repair packs and replacement materials.

To that goal, buffer chests should never receive items before requester chests when supply is limited. You don't want your turrets running out of ammo during an attack!

Function as a "high priority provider" to take away waste products (e.g. empty barrels) that are also being crafted and placed in a passive provider.

1. Definitions

A "trash action" is generated by the player trash slots, active provider chests, and deconstruction orders.

An item is "provided to the network" when it is sitting in a passive provider, buffer, or storage chest; or it is the subject of a trash action with no assigned robot.

An item is "requested" by construction orders, player logistic requests, requester chests, and buffer chests.

An item request is "standing" if there is no material available to satisfy the request. This is represented in the logistic network contents as a 0 or a negative quantity, depending on TODO.

An item is "newly provided" when it becomes provided to the network while there is a standing request for the item.

An item in a buffer chest is "mismatched" when the item is not present in the filters set for the chest. An item is not considered mismatched if the filter is present yet set to 0.

2. Requesting priority - supply > demand

When an item is requested, the items need to come from somewhere. Each of these sources should be checked, in order, for the items:

1. Trash actions
2. Storage
3. Mismatched Buffer Chest contents
4. Passive provider chests and Buffer chest contents, based on distance (Buffer chest contents that are not mismatched cannot be used to fulfill requests from buffer chests.)

3. Providing priority & Trash - demand > supply

When a newly provided item fulfills standing requests, the standing requests should be fulfilled in the following order:

Additionally, when a trash action is providing an item, the destination should be selected in the following order:

1. Construction orders
2. Player requests
3. Requester chests
4. Buffer chests (Buffer chests can only take mismatched contents from other buffer chests)
5. Storage (Only when item is being trashed - mismatched contents are not placed in storage)

4. Summary and conclusions

All the named use-cases are covered.

Buffer-buffer Loops are prevented, because buffer chests cannot take from other buffer chests the items they're requesting.

Buffer chests can supply items to construction robots, and reduce robot travel time by placing them close to future build orders.

Buffer chests can supply the player when they return to base, assuming there is no excess items in storage.

Buffer chests can supply items to requesters. Buffer chests can be used to reduce robot travel time by placing them nearby to requesters. (This satisfies the "reloading gun turrets" usage.)

Buffer chests can function as "high-priority providers" (e.g. removal of waste products from modded recipies) by simply leaving their filters blank.

Buffer chests do not recieve items before requester chests do.

5. Changelog

15 December - wrote initial version in Friday Facts forum thread
15 December - adapted to Reddit and posted to very few views (I posted it at the wrong time of day)
19 December - Adapted to forum, posted in Suggestions.
19 December - Added concept of "mismatched" buffer chest contents.
19 December - Changed concept of "mismatched" to not care about the quantity, and allow 0-request filters.

Re: Proposal for Buffer/Requester Interactions

Posted: Tue Dec 19, 2017 10:32 pm
by riking
I have been informed this definition of "mismatched contents" will be great for the next version of Mojo's Make Everything Factory - currently, it has an inserter wired up to empty the assembler's requester chest into the provider chest once the ME request has been satisfied.

With buffer chests, by instead simply clearing the Set Filters wire, the buffer chest's contents become "mismatched" and picked up by the next request for the materials (which will usually be a nearby machine!)