Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: re minecart logic, am i smoking crack?  (Read 3562 times)

Nil Eyeglazed

  • Bay Watcher
    • View Profile
re minecart logic, am i smoking crack?
« on: February 15, 2014, 02:51:36 am »

Checking out minecart logic today (which I'm wholly unfamiliar with, btw) and I'm seeing a memory section, followed by a power-to-signal section containing multiple designs.

Aren't all examples of PTS also examples of memory, via toggling gears?  I don't just mean for just minecart logic, but always.

Lacking a little confidence, because I've been known to get things incredibly wrong in the past, lol, hoping somebody will agree with me or explain why I'm wrong.  Anticipating making some changes to that page, adding what logic gates I can find and understand, but also getting rid of some of the redundancy.
Logged
He he he.  Yeah, it almost looks done...  alas...  those who are in your teens, hold on until your twenties...  those in your twenties, your thirties...  others, cling to life as you are able...<P>It should be pretty fun though.

Larix

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #1 on: February 16, 2014, 08:27:38 am »

I've been rather hesitant to mess around with the minecart logic page, since i feel quite out of my depth trying to judge which circuits deserve their place and which could go. The two memory cell designs are, if i understand this thing right, set-/reset latches, and as such, they're very compact and fast and so certainly worth showing. The power-to-signal converters are an important interface tool to make mechanical logic useful. I agree, it's not really necessary to show three designs of PSC, complete with modular arrays of a dozen of them. And one memory cell design could also suffice, seeing how they're essentially the same, just with two slightly different optimisation objectives.
I once again tried to understand the "modified load adjusted memory cell" and now strongly suspect that it has no merit: it appears to do nothing but turn an on/off into another on/off, consuming a lot of machinery and adding delay without achieving anything that couldn't be done by directly linking a lever to the actual receiver.

Terminology: i _think_ that latches are usually circuits that take an input and "hold" it, i.e. do not change again when the same input changes, but wait for a _different_ signal to re-set, enable/disable/clear/whatever. Important when you have a temporary signal, e.g. from a pressure plate, and want to use it to e.g. permanently open a door.

Power-to-signal converters are more of an internal data processing necessity of DF, because mechanical logic's direct 'output' is only power, which first must be 'converted' to a signal to open a door or somesuch.

There are many logic circuits possible with powered and un-powered minecarts, but powered minecart logic isn't a very useful tool for the AND/NOT/NOR etc. logic gates. Those are smaller, faster and more reliable when done in mechanical logic, while minecarts shine where data storage, signal conversion, repeaters and incrementation are concerned.
« Last Edit: February 16, 2014, 10:50:01 am by Larix »
Logged

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #2 on: February 16, 2014, 03:44:54 pm »

I started working out my response and quickly realized that I had been, in fact, smoking crack :)

Memory designs are signal-splitters-- that is, they get sent a full signal cycle, and output only half of it (an 'on' or 'off' signal in response to 'on...off'); usually there are two inputs, determining which half of the signal gets sent, with second and subsequent inputs of the same type ignored.

Power-to-signal is just identity, for transmitting signal via load-based mechanical logic.  If you send a PTS a power on-off, you expect it to send full signal cycle.

(At continued risk of being drastically wrong, so corrections, as always, are very welcome)

That out of the way:

I think the newton's cradle memory cell is, while not the smallest, probably the simplest of the memory cells to describe, and perfectly functional.

I think the 2x2 power-to-signal device is probably the most desirable of the PSCs.  (I might edit the mechanical logic page and/or memory pages a bit to talk about PTS.)

Other than that, I don't think any of the circuits on the page should stay; the link to Bloodbeard's thread should be sufficient for people who want more in-depth exploration (and don't mind working their noggin to do so).

There are many logic circuits possible with powered and un-powered minecarts, but powered minecart logic isn't a very useful tool for the AND/NOT/NOR etc. logic gates. Those are smaller, faster and more reliable when done in mechanical logic, while minecarts shine where data storage, signal conversion, repeaters and incrementation are concerned.

I've never messed much with load-based mechanical logic because it never struck me as very intuitive, and I doubt I'm alone.  Of course, the real point to this stuff isn't the practicality.

But I agree that unpowered minecart logic is much, much more useful than powered minecart logic.  I think it's worth giving some time to the differences.  Other logic disciplines have their subdisciplines, after all.

AND/NOT/NOR etc should be on the page, I think, because they're kind of like lego bricks: once you have circuits that can do them, you can build the same device in numerous different ways, without having to understand what's actually happening.

It would be surprising to discover that, for instance, a minecart adder was really tiny, yet a minecart XOR couldn't be designed small, considering that XOR is the heart of addition.  If it was the case, it would certainly be worth going into detail on that.
Logged
He he he.  Yeah, it almost looks done...  alas...  those who are in your teens, hold on until your twenties...  those in your twenties, your thirties...  others, cling to life as you are able...<P>It should be pretty fun though.

Larix

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #3 on: February 17, 2014, 10:30:20 pm »

Power-to-signal is just identity, for transmitting signal via load-based mechanical logic.  If you send a PTS a power on-off, you expect it to send full signal cycle.

Power-to-signal converters are needed to transmit the pure power output of mechanical logic arrays to other devices that need a signal input. If you want to close a floodgate by turning a lever _on_ or if it should only close if _two_ levers get switched, you can run your input signals through gears for quick and easy processing, but you'll need to turn the axle rotation into a signal again to operate the floodgate. That's where PTS come in. They _are_ identity switches, but they are switched by identity with power, not signals. Trivially, a proper PTS can be turned on by building and turned off by deconstructing an axle.

I fiddled with collision-based minecart operations a bit, and came up with a pretty compact and elegant ternary incrementer, as well as a compact binary incrementer/decrementer. (Edited them into my massive collection thread, second post.) The latter's pretty much an analogous development to the one Bloodbeard posted in his thread, just a bit more compact and with cleaner pathing (Bloodbeard did his work before proper minecart switching through rollers had been worked out and relied on the shoddy "scrape it along a wall" switches).

The memory cells (S/R latches?) on the wiki page can be done powerless, as well, at the cost of massive latency:

Code: [Select]
#     #
▼     #
▼     ¢
║     ^
▼     ¢
▼     #
#     #

Straight N-S track on the flat tile above and on the ramps below. Two carts of different weight and a weight-sensitive pressure plate, two hatch covers, one operated by the "set", the other by the "reset" signal. One cart will always sit on the pressure plate, the other on a hatch cover. If the hatch is opened, the cart falls inside, rocks back and forth through the pit, bumps into the cart on the pressure plate and pushes it off - to the other hatch cover - then, after another cycle through the pit, climbs out and sits on the pressure plate.

The nice thing is that on the level above, only two hatch covers and a pressure plate are visible. It actually takes 1x7 tiles on two levels. Latency is awful - 42 steps for a "set", 126 for a "reset". I wouldn't put it on the wiki page.
Logged

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #4 on: February 17, 2014, 11:21:54 pm »

I see what you've got on the page now.  I still think there should be more circuit examples on the actual page, because people will clarify the wiki page but not your user page, and because I think your examples are a little difficult to puzzle out.  At least, they have been for me.  For instance, I've been trying to figure out your spin memory, but can't really understand how everything is supposed to work, which is why...

I've started a map so I can figure out some minecart logic issues.  Still just at the minecart basics though (hard to turn off the muscle memory that runs me through the first year, lol).

I'm considering a different way of organizing the page, though.  Rather than providing a phrase-book of mini-circuits like there is for the other pages, it might make sense to pick circuits based on how well they represent different ways of approaching minecart logic.  For instance, newton's cradle memory design, roller derailer AND/OR gates, altered path via bridge/hatch, etc.  Any thoughts on that philosophy?

In any case, have started trying to work minecart logic into a few of the other computing pages.
Logged
He he he.  Yeah, it almost looks done...  alas...  those who are in your teens, hold on until your twenties...  those in your twenties, your thirties...  others, cling to life as you are able...<P>It should be pretty fun though.

Larix

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #5 on: February 19, 2014, 08:51:37 am »

Getting started with minecarts can be quite confusing and frustrating. It took me a good while to get past the quirks of track engraving and route management. Good luck!

I think the wiki page could profit from being more of a presentation of minecart logic approaches and possibilities. There's Bloodbeard's and Tinypirate's power-and-indirect-pushing approach which makes for very small and configurable powered latches and can be used for an incrementer.
There's the approach with moving minecarts, still just converting roller activity into signals but with various practical applications. I often use variations of the most minimal minecart/power interface for various signal processing purposes:

Code: [Select]
#===#   #R^R#

Just three tiles of straight track between two walls, rollers pointing inside, a pressure plate in the middle. A single minecart. Depending on how you wire up the power supply of the rollers, this can be used as a power-to-signal converter, as a repeater or to convert "held" signals or lever-pulls to signal-pair "pulses" (what's often called an "edge detector"). The PSC and repeater can even be built with only one wall, although that'll consume power while idling and has a longer period on the repeater (~108 instead of ~105 steps, so not a huge deal).

I think that'd be a pretty useful thing to put on the wiki, considering how large and unwieldy these things can become under other logic doctrines. It's still just an extension of mechanical logic.

Then there are the various ways of turning minecart path decisions into logic, and that's where my hatch/ramp stuff comes in, but the same basic principle's also used for derail-speed switches and the switching of powered minecarts. I actually think my shift register is a good example of powered minecart logic - there's a lot of mechanical machinery involved, but the actual information is held by absence or presence of minecarts in the memory rows, a memory status is not represented by gear states.

There's also the question whether to show off a bunch of standard "computing components" like latches, logic gates, repeaters, or larger-scale applications like a clock or dwarven lunar calendar. Or some sort of mix between the two?

Spin memory - i'll try to demonstrate its workings from the ground up:

« Last Edit: February 19, 2014, 05:24:50 pm by Larix »
Logged

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #6 on: February 20, 2014, 12:35:10 am »

I think I see the spin memory-- but I have to build it to make sure.

Have to try out a few of your designs.  I didn't see paired impulse ramps lifting minecarts, but I never had them adjacent either, always at least a tile of separation.

Newton memory can demonstrate a principle, and offer a compact latch at the same time...

Totally agree re: your PSC, better and simpler than the 2x2.  I plan on replacing the whole PSC section with that, with the hint that minor modifications can make an edge detector or a repeater, maybe leave that as an exercise for the reader...

Or, maybe just spoil it for the reader, because Repeater page should have a minecart example, and I'm considering creating an edge detection page (one of the more useful gadgets thanks to demand for resettable trigger-once)...

Bridge-derailment, impulse-ramped NOT should demonstrate those principles and open readers eyes to powerless possibilities....

Roller-derailment AND and OR should demonstrate that principle, with a note that NOT, AND, and OR are enough to build XOR, NOR, NAND, and XNOR....

Then there's outside links, which should be several of your threads as well as Blackbeard's thread and probably a few others search turns up, room for peeps to talk about their own cool inventions, user pages, and I think it should work pretty well?  In terms of demonstrating ways to do it, offering everything or almost everything needed to do it, and lots more to read for those that feel like it?
Logged
He he he.  Yeah, it almost looks done...  alas...  those who are in your teens, hold on until your twenties...  those in your twenties, your thirties...  others, cling to life as you are able...<P>It should be pretty fun though.

fricy

  • Bay Watcher
  • [DFHACK:ZEALOT]
    • View Profile
Re: re minecart logic, am i smoking crack? Or maybe Toady was? :)
« Reply #7 on: February 21, 2014, 10:47:43 am »

I wasn't sure where to post it, since you two seem to have a fire going on regarding minecarts. :) Anyway, I always had a thing for Larix's circuits, and the spin memory bugs got my interest. So I looked at them with dfhack, to see what's happening.

I built this track (more or less, with a 5 tiles entrance track from the south), pushed a cart in and logged the speed values to see if I can make any sense of it.
Code: [Select]
╔▼▼╗
╚=╔╝

The most relevant part of the data is this, from the first step on the down ramp to the first step in the corner after the up ramp. Full log is here in a more readable format.
Code: [Select]
16,41763 -0,58237 -0,1655 -0,1655 47 0,441 0 0,1756 151 -1
16,26604 -0,15159 -0,2144 -0,0489 47 0 0 0 151 0
16,07987 -0,18617 -0,2633 -0,0489 47 0 0 0 151 0
15,85913 -0,22074 -0,3122 -0,0489 47 0 0 0 151 0
15,60381 -0,25532 -0,3611 -0,0489 47 0 0 0 151 0
14,5 -1,10381 -0,361 0,0001 47 0 0 0 151 0
13,5 -1 -0,3609 0,0001 47 0 0 0 152 1

Extra emphasis on the up ramp:
Code: [Select]
14,5 -1,10381 -0,361 0,0001 47 0 0 0 151 014,5: starting position, this is where we enter the ramp
-1,10381: distance travelled to get here in the previous tick= 1,1 tile
-0,361: cart speed = 36100
0,0001: tile friction

It looks to be the same bug I found a few months back with alternating up ramps and flat tiles, where after a certain speed treshold upramps do not "generate" ramp friction, but flat track friction. Only this one is even weirder, as that one needs 71k speed to kick in, (sqrt2x50.001) this one works with any speed. My guess in this case is that Toady didn't take into consideration, that you can build an up and a down ramp without a flat tile in between, and the game will treat the upramp as a flat track. And my 2c is that this shouldn't work this way, in real life if you try to build such a track, the cart will inevitably get stuck in the pit.

By the way, you lose control of the cart when it's speed is more then 50k right before entering the down ramp. Then it flies above the pit and slams into the wall.
My untested conclusion is that you can't catch a derail speed minecart with a corner track, but you -may- be able to stabilize this circuit by enlarging it to 3x6 tiles, so there's a one tile regular track after the ramps. That way the cart will enter the pit on every other circle, fly over the pit in the next, and lose 4k speed on the corners. This adds latency of course, but may be worth a try.
Tested, first fly over behaved as predicted, second got stuck in the corner. Seems to be connected to how far the cart flies when unstable. Without track stops to regulate speed this will not work.  ::)

I wonder I we should put together a save for Toady illustrating all minecart bugs in one go for the upcoming Bugfixing Fiesta. There are quite a few edge cases that does not work as intended, most of them to do with going from flat tracks to ramps.
« Last Edit: February 21, 2014, 11:30:09 am by fricy »
Logged

Larix

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #8 on: February 21, 2014, 09:25:53 pm »

Hehe, i tried out something based on this plain ramp with full loop as a spin memory once, but yeah, it's hilariously impractical: since the cart is entering the pit in a straight line, it gets the full acceleration, which puts it above derail speed after three passes, i think. It could be made to change direction, but only by closing bridges, which have a nasty habit of throwing carts around sometimes. And it took four medium-friction track stops to remain stable.

I don't know how feasible a "bug fort" would be, some are extremely capricious and weird, often difficult to replicate, let alone understand. I'd certainly be willing to participate in such an endeavour, i've dug up quite a bunch of strange things.
Logged

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #9 on: February 26, 2014, 04:03:14 pm »

So I think I'm done with the changes I planned to the minecart logic page.  I have some thoughts regarding it though:

1) I'm not sure that the techniques mentioned in "other techniques" shouldn't be demonstrated.  That's just how I ended up doing it.
2) The key is too big.  Ideally, it would be a paragraph in a smaller font, or a sidebar without actual sentences and such.  I don't know how to do either, so I didn't.
3) I got rid of a lot of stuff.  Almost everything, actually.  I hope I did so towards a good end, I hope it's clear why I got rid of what I did, and I hope people feel free to replace things if they disagree :)
4) Some of the diagrams would benefit from empty space, but I don't know how to do that.
Logged
He he he.  Yeah, it almost looks done...  alas...  those who are in your teens, hold on until your twenties...  those in your twenties, your thirties...  others, cling to life as you are able...<P>It should be pretty fun though.

lethosor

  • Bay Watcher
    • View Profile
Re: re minecart logic, am i smoking crack?
« Reply #10 on: February 26, 2014, 10:34:20 pm »

For diagrams, you can use spaces=yes (which I think you're doing), add line breaks around them for more vertical space, or wrap them in a div for padding. I'll take a look tomorrow and try to help with a couple of those things.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.