Page 1 of 1

Need help designing an auto trader

Posted: Sun May 20, 2018 4:56 pm
by valmarus
I'm trying to design a railway station that can allow trade between two players. When the train stops one side unloads raw materials and the other side inserts the item being used as currency (in this case research packs). I've been trying to use combinators to turn inserters on and off but I always seem to get to a stage here unloading the last chest in the sequence causes the entire system to fail.

I've used a number of different combinations of arithmetic, constant and decider combinators; I've used various connection styles such as connecting everything to everything or only the required inserters to the chests they need to read; and I've tried various methods from simply reading chest contents to tracking a constant in increasing the incriment by 1 at each stage before resetting it at the end; but I just can't seem to crack it. The footprint needs to be as small as possible also.

Image

The reason I'm trying to load directly from and to the train is to allow multiple players to simply send their trains to the same resource selling station though if you're having problems coming up with something that doesn't have a huge footprint and have ideas for another design I'd be interested in seeing it.

Another thing I'm going to be looking into is making the station easily programable perhaps by having a master chest for the sale item and buy item which putting the quantity you want of each determines how many is needed to meet the conditions for loading/unloading all other chests but haven't got that far yet.

Re: Need help designing an auto trader

Posted: Sun May 20, 2018 6:23 pm
by DaveMcW
trader.jpg
trader.jpg (89.59 KiB) Viewed 2296 times


The left chest is a buyer, it removes items from the train and inserts currency.

The right chest is a seller, it removes currency from the train and inserts items.

You can buy/sell six different items per wagon.

The arithmetic combinator can be used to increase or decrease prices up to 12x. Note that you may need to reduce inserter stack size or set a more complicated red wire condition to avoid rounding errors. (You could set prices up to 132x if you run 11 inserters in parallel, but that is left as an exercise for the reader.)

Re: Need help designing an auto trader

Posted: Mon May 21, 2018 5:00 am
by ColonelSandersLite
A question -

How are you wanting the player to control what they're buying?

Maybe a station for the purchase of each purchasable good? For example, perhaps you're wanting a system that will let a player send a train with x science packs, and return with y iron plate?

Re: Need help designing an auto trader

Posted: Thu May 24, 2018 8:42 pm
by brockmasters
too bad constant combinators could really mess this if this a player vs. player element fyi

escrow base?

Re: Need help designing an auto trader

Posted: Fri May 25, 2018 12:57 pm
by valmarus
Thank you for the design DaveMcW. I've had very little free time of late and I'll try it once I get a chance.

ColonelSandersLite, yes I was planning to have a station for each trade type.

Re: Need help designing an auto trader

Posted: Tue Jun 05, 2018 5:16 pm
by ColonelSandersLite
Well, here's my solution, in two slightly differing variants. It's easy to configure, very fast, and precise.

20180605110654_1.jpg
20180605110654_1.jpg (874.78 KiB) Viewed 2068 times
20180605110700_1.jpg
20180605110700_1.jpg (861.96 KiB) Viewed 2068 times
Note that in both variants, the roboports exist solely to stop the creative chests from blinking and server no other purpose.

Both variants have a very slight issue. If a player purchases more good than the train can actually hold, some or all of the inserter arms will end up stuck holding the goods over the train car. The next train that comes through will get those goods free of charge. I guess the moral is that you shouldn't buy more stuff than you can carry.

Version B is a somewhat streamlined version that has a bit of a problem. Since version B does not attempt to balance the load between the cars, the math on the inserters can result in imprecision. In particular, when a train is very nearly full. For example, purchasing 16,000 plates will result in the loaders attempting to put 3,996 plates in wagons 2-4 and 4012 in wagon 1. Version A would put exactly 4,000 in each car. If precision isn't particularly important, the more streamlined version B might be useful, but I would honestly just use version A.



Here's the demo:
Autotrader Demo Rev 1.zip
(3.84 MiB) Downloaded 70 times
Game Version - V 0.16.36
Mods - Creative Mode (Fix for 0.16)



Notes -
Configuration is done by setting values in two constant combinators.

The accepted currency and price defaults to 3 red science. You may reset this to whatever you want (10 copper plates, 1 nuclear reactor, 500 yellow potions, whatever).

The bundle of goods received per transaction defaults to 16 iron plates. Again, you may reset this to whatever you want.


Edit:
After posting this, I realized that there's a small bug in Version A (because of course there is...)
Above each wagon loader, there is an arithmetic combinator: W/60=S
Each of those should be: W/72=S