Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Time Delay Logic  (Read 5187 times)

nanomage

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #15 on: June 17, 2011, 08:33:20 am »

I think pitting a goblin and empirically picking a distance he has to run to trigger your watch once per given period of time is the best bet. Animal and water are unreliable, unlike gobs, who are strongly and reliably driven toward the edge of the map.
That, or some kind of mechanism reacting to ice melting, but this will only trigger once per year.
Logged

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Time Delay Logic
« Reply #16 on: June 17, 2011, 08:47:54 am »

Well, I had considered that, and decided that this animal needs to be toyed with.  I will likely make a non-speaking invader civ, so they'll send sieges that I can wipe out easily, and it means that I'll have an endless supply of capturable creatures.  This gives them the map-edge priority of an escaping goblin, and the uniform movement speed of a predefined creature.

Root Infinity

  • Bay Watcher
  • Why?
    • View Profile
Re: Time Delay Logic
« Reply #17 on: June 17, 2011, 10:45:17 am »

Hmm... sounds like you want a clock more than a timer...

Try this:
Code: [Select]
###### ###### ######
#_<% # #_%>a# #b####
##A### ##B+## #+####
#>*### #XE### #<####
###### ##|### ######
Z + 1  Z      Z - 1
--------------------
# = wall
  = floor
_ = dug out (channel or no floor)
A,B = gear assemblies, connected to
a,b = pressure plates (1-7 water)
E = enabling input
> X < = stairways
* = gear assembly
+ = door
| = axle

Add 2 units of water.
Shamelessly ripped from Hussell on the DF wiki.
Then just build 168 of these, each connected to the next :P Jkjk...
You want 42 repeaters worth open, then 126 closed, in other words 2*3*7 open, then 2*3*3*7 closed, or grouped (1 open 3 closed)*2*3*7... Easy enough.
Build 16 of these like this:
ABCD
EF
GHI
JKLMNOP
In each row connect each repeater's top pressure plates to the top gear assembly of the next one in the row. The last one gets connected to the bottom gear assembly of the first one in the row. Do the same for the bottom pressure plates.
In each row connect the first top pressure plate to the enabling inputs of the next row up. The bottom row does not need an enabling input. Then you just connect the output of A to the well!
Logged
Classic Medieval sexist views are awesome when they work out in your favor.
Noone likes my witty comments enough to sig them.

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Time Delay Logic
« Reply #18 on: June 17, 2011, 11:09:00 am »

Wow, that's some heavy shit.  But, a fully-powered one-day exact repeater is fantastic.  From there, I can use some logic gates, albeit some massive logic, to create any number of repeating signals.  At 336 days per year, this is quite the task, but could be creatively compacted using some form of binary counter or creative holding sequence.  I'll have to ponder over this...

Funburns

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #19 on: June 17, 2011, 11:10:10 am »

Ugh, apparently hitting ctrl-R causes Firefox to reload the page, wiping my post. This is therefore a frustrated, abbreviated rehash of something I already wrote, a feeling I'm sure everyone knows. :P Also, semi-ninja'd by Root Infinity, but you don't actually need any more than a small number of properly connected repeaters to measure great lengths of time with perfect precision, as I'll explain below.

Water logic repeaters can easily be designed to be precise and predictable to a precision of one step. The way it works is the pressure plate the water was on before the pump reactivated is what does the actual timing of the repeater. Since the pump moves the water and it collects on top of a pressure plate in less than 100 steps, the resetting of the previous pressure plate connects seamlessly with the resetting of the current one in an endless cycle. No uncertainty enters the repeater from any source, not even the real world computer's speed.

The effect is so precise that the build order of the mechanisms, pressure plates and pumps themselves can introduce a consistent 1-step delay that can actually be used to measure time that way with sufficient thought and additional engineering. Useful for your dwarven particle physicists.

http://df.magmawiki.com/index.php?title=DF2010:Repeater&oldid=143369 holds everything needed to construct a 400 step repeater. This is precisely one third of a dwarven day, which means connecting a pressure plate into a separate, three-plate repeater, as seen in http://df.magmawiki.com/index.php?title=User:MrFake/NStepCyclicRepeater&oldid=127305, creates a flawless 1200 step repeater, or one full game day.

Using this chaining logic, additional repeaters can be connected up in a giant chain that uses the basic 400-step repeater as the foundational clock. Remember, only the first repeater actually measures time -- the following repeaters measure increasingly large cycles of the first, fastest repeater. Any unit of game time can be measured out metronomically this way, including Girlinhat's 8,400 and 25,200 cycles.

The whole thing's really so simple and relatively quick to set up that I think I'll make a calendar in my current fort sometime today or tomorrow.

celem

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #20 on: June 17, 2011, 11:48:00 am »

I build something a little like this once.  I wanted raising drawbridges to roof my above ground dininghall that opened automatically every summer but were closed the rest of the year.

Getting a year long cycle was more than i had the time to invest but i played about with some shorter stuff.
My solution was a greatly elongated goblin repeater (your modded-speed critter is good for making it shorter), as he pathed up and down he hit many many pressure plates that controlled floodgates in a descending ramp passage with water at the top.  The result was that every 500 tricks or so the water dropped another level, by the end of 3 weeks or so it would reach the bottom and trip a pressure plate that toggled my roof open.  You run a smaller timer to then close it and reset the first.  My smaller timer gave me about 4 days of sunlight and then closed the roof and pumped out the first timer.  I had to do some crazy micromanagement stuff to trap the goblin once he reached the end and had opened the roof, then release him after the open cycle to path again, he spent the open days taking a shortcut route back to the start (to avoid the plates and make it in 4 days).

Crazy hassle, took years.

It was my first fluid logic experiment though and while temperamental it worked after a fashion, no cave adapted dwarves
(I know its not actually necessary to get a tile to show above ground but it looked cool)
« Last Edit: June 17, 2011, 11:58:46 am by celem »
Logged
Marksdwarf Pillboxes
I wish I had something cool to say about this.  Because it's really cool.

BloodBeard

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #21 on: June 17, 2011, 11:55:15 am »

I approve this evil tyrant fort.

Speaking of which, how about you segregate a small group of McScientist dwarves from the rest of the fort to live in luxury and study your miserable dwarves behind clear glass walls.

Funburns

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #22 on: June 17, 2011, 12:02:57 pm »

I forgot to put in my previous post the actual numbers of pumps you'd need for a monthly repeater using the multiplication method.

A 400 step repeater requires 4 pumps, a daily repeater also requires 4 pumps (check the 3x repeater design in on the wiki). A month requires a 7 repeater (one week) and a 4 repeater (one month). Connected properly, only 19 pumps are needed. All you'd have to do is put an extra mechanism connection on the final (one month) repeater to indicate when it was the one week period you wanted. There's no need for chains of hundreds of pumps when only 19 are necessary.

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Time Delay Logic
« Reply #23 on: June 17, 2011, 12:07:53 pm »

That's the idea, I need a "control group" in case the poor sods actually kill each other, I'll still have a fort that can attract migrants.  I think I'll be implementing some of Hussel's ideas, as they seem to make the most reliable timers for long duration.  If I can isolate 8,400 ticks apart from the rest, then it's a very simple matter of making some other fluid logic to store the counting information and reset yearly.  Since there's a working day-long repeater, I'll probably make one of those to isolate weeks apart from each other, and then isolate the weeks into month-long units of time, and then reset the assemblage every 12 months.  In practice, this means that I'll be using the repeater instead of the creature, because the rest will remain relatively unchanged.

NINJA: Funburns, I'm having trouble wrapping my head around the exact method the wiki lists.  It's well-diagrammed, but the colors and complexity throw me off.  Could you explain what you mean a bit better?

Psieye

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #24 on: June 17, 2011, 01:30:09 pm »

Speaking of which, how about you segregate a small group of McScientist dwarves from the rest of the fort to live in luxury and study your miserable dwarves behind clear glass walls.
No, this ruins the purpose of her fort: to get fell moods and macabre moods. Ideally, every dwarf should be miserable so any mood will be an evil one. The fort should be segregated into groups though, so that one tantrum spiral will have a limit to how much damage is done should the helmets fail.
Logged
Military Training EXP Analysis
Congrats, Psieye. This is the first time I've seen a derailed thread get put back on the rails.

Tharwen

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #25 on: June 17, 2011, 01:41:49 pm »

Couldn't you simply mod in a creature that moves at a rate of one tile every season and put it in a long corridor full of pressure plates?
Logged
[Signature]

Funburns

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #26 on: June 17, 2011, 02:03:34 pm »

Reading Hussell's repeater design, it seems like that would work too, but it is somewhat more complicated than the circular designs such as MrFake's. I'm not completely sure if Hussell's design is precisely correct since I haven't read it before and I don't see the reset mechanism there.

MrFake's n-step repeater can handle the same jobs, though. While it isn't necessary for the purpose of constructing a clock,  it is possible to duplicate Hussell's core 100-step repeater (actually an incrementer on the wiki, since I don't see a reset mechanism in the diagrams)  using MrFake's design by constructing a 200-step or 400-step repeater and removing pressure plates to get it down to a 100-step repeater, the same way a 3x is produced from a 4x n-step.

Perhaps this step by step description will give another way of thinking of the repeater's operation:

Spoiler: Methodical Description (click to show/hide)

Spoiler: A Different Diagram (click to show/hide)

Hmm. After typing all that, I don't know if it'll actually make it easier to understand. I hope it does. :)

To connect the 400-step repeater into a 3x repeater (for a 1200 step cycle time), another, separate repeater must be constructed like the 400-step one, and it must be made to increment as a 3x repeater once every full cycle of the 400-step repeater. This can be accomplished by setting up a secondary signal from one of the pressure plates in the 400-step repeater and tying it to a NOT gate, which then is tied to the 3x repeater's power train. This causes it to effectively work like as if it was a 300-step repeater, except that only advances one increment every 400 steps, for a total loop time of 1200 steps.

Jyppa, the original designer of the calendar, created an instant-effect NOT gate using a "resistor" room of enough gears to stop the power train of the 3x repeater. It worked by connecting the power train of that 3x repeater to the large room of power-draining gears when the input from the 400-step repeater was NOT there (chosen pressure plate in the 400-step repeater NOT pressed = connect power train to resistor = stop 3x repeater while 400-step repeater is making another round). If there's a more elegant NOT gate that's also purely mechanical (doesn't rely on another 100-step pressure plate, that is), I can't think of one at the moment. It's worth noting Jyppa solved the day counter somewhat differently, with a 14-pump 1200-step single unit repeater instead of a 400-step and a 3x repeater. The upper cycles are the same, though.

If this doesn't clear things up, could you specify which part needs explaining?


Edit: Oops, forgot to fix some letters from the first draft. Also fixed misleading inconsistencies between explanation and diagram - the diagram does not copy the explanation, which starts from the first launch of the repeater. The diagram shows the repeater looping. >_< To think I reread this twice... Also see: http://mkv25.net/dfma/movie-1370-pump-basedautorepeater for demonstration of the 400-step repeater alone.
« Last Edit: June 17, 2011, 02:35:50 pm by Funburns »
Logged

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Time Delay Logic
« Reply #27 on: June 17, 2011, 04:26:02 pm »

Oh!  So it works by using the pressure plate's resetting delay to pause the second next pump in line!  Since water moves faster through pumps than the pumps will reset themselves, the speed of water is restricted in 100 unit increments due to the plate delay.  Fantastic!  Now I just need to wrap my head around Hussel's 1200 step repeater, because the "period doubler" isn't explained very well.

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: Time Delay Logic
« Reply #28 on: August 22, 2011, 04:50:15 am »

Necro-ing because this is my cup of tea, and I can add meaningfully.  This is my goblin-based day cycle:



The goblin has just advanced through an open door onto a hatch, and from there onto a pressure plate that caused hatches in front of and behind him to open.  The hatches on the pressure plate he just left have not yet closed, but they will, in like 50 ticks.  In something like 350 ticks, the door in front of him will open, the door (that's open in this picture) behind him will close, and he will advance forward again, to become trapped on the next pressure plate.

This goblin cycle is driven by a four-step repeater as described earlier.  Two opposite pressure plates on the four step repeater are attached to alternating doors around the outside of the cycle (the inside doors are so I can do a manual adjust rather than having to make sure the goblin and my repeater start in the exact right position).  That means that at time = 0-100, one set of three doors are open; at time = 200-300, the other three doors are open.

Each pressure plate is linked to the adjacent hatches.  Note that the design of doors and hatches allows progress onto a hatch, but no retrograde motion.  Each pressure plate is also linked alternately to one of three exits from the cycle to permit the goblin to think he has a path.  Three exits are necessary because with two, adjacent pressure plates need to be linked to the same door, and the goblin will reach the pressure plate before the close signal has come from the previous pressure plate-- so he'll land on a pressure plate, the door will close after that, and he won't think he has a path next time he's capable of advancing.  Note that these paths have to be unobstructed paths to a map edge.  If you build this under your fortress and then close the bridge, it'll stop working.  I worked around this by building it separate from my fortress, just in case, connected to the surface by an indestructible, securely closed artifact hatch cover-- everything with hands that wants to kill goblins is also a building destroyer, so it works.

Just as two ends of my 4-step repeater are linked to alternating doors, two ends of this 6-step goblin cycle are linked to alternating doors in a 14-step week cycle.  I haven't done it, because I got bored, but the week cycle can be linked to a 8-step month cycle, which can be linked to a 24-step year cycle (although really you'd use a 8 step linked to a 6 step for building efficiency).

So if the 4-step cycles every 400, why do I need a 6-cycle?  Days are 1200, so couldn't I use a three cycle?  No, the alternating doors require that the goblin move 2 steps for every cycle of the previous repeater.

Note that this style of incrementation (creature-based incrementation) is totally arbitrary.  Water-based incrementation would be simpler.  You can use a series of alternatingly-triggered bridges to control the motion of water down from a source to an exit tile for the same effect, and it's much easier (although for instance a 14-step water drop would require something like 21 z-levels, at least, if you wanted a pressure plate on every step).  Linking pump-based repeaters to pump-based repeater is fine too.  No matter what you're doing, you're just moving a bit of information (creature or water) from cell to cell with every half step of the cycle driving it.  There's no need for huge power sources, no need for giant load-providing gears, no need for fluid-logic (well, it's all logic anyways, really).

Now, originally I wanted to use a completely goblin-driven clock.  I never considered modding, so it might be possible if you use every tool in your arsenal.  Here are the problems I ran into:

a) Actual fortress-mode creature speed is poorly understood right now.  Dree12 and I did some research on the effects of attributes on speed here: http://www.bay12forums.com/smf/index.php?topic=91016.0  You don't have to understand that big nasty equation or ever use it, though, unless you want to make some weird delays; the shortcut is that a creature who's strength+agility=2267 moves at unmodified speed (move at 0, 10, 20, etc for default speed 900 creatures, what I call delay=10).

There's a huge caveat to that: it only works in arena mode.  The same principle applies to fortress-mode creatures, but there appears to be other factors at work as well; since arena mode creatures spawn without traits, I suspect that's where the noise is coming from, but I haven't figured it out yet.  I suspect that if you used DFmode to switch to arena, spawned a creature, used runesmith to set its agility and strength, then switched back to fortress mode, you could make a perfect delay 10 creature (or delay anything else, from 6-15 for speed 900).  However, I have no idea how such a creature would path.  Probably editing flags could get it to path how you wanted.

b) Diagonal motion.  Basically, it's a big no-no.  You could potentially build a timed creature loop using entirely diagonal motion, if you wanted an abnormally slow movement, but there is no reasonable value of delay that leads to an integer for moving both orthogonally and diagonally (a super slow creature could potentially have such a value, but we're talking like 128 times slower than normal).  So you're stuck with orthogonal motion, which limits designs.

c) Timing issues.  When a goblin loses all paths, I can't predict how it behaves.  (Some of its behavior is predictable-- run it into a hatch-plate combo without a path behind it for another delay ticks but with a path available before delay*2, and it falls, gets up, such that it takes 5 movements to go the other way.)  When a goblin has multiple paths, I likewise can't predict how it moves (it doesn't just adopt the shortest path).  You combine that with fixed trigger times (plates trigger open when creatures step on them, close 100+delay steps after they step on them) and you start getting into some math-crazy territory where I am personally out of my depth.  What it amounts to is that a goblin of a given speed will move predictably on a path of a certain length, but not on one of another length, either longer or shorter.

EDIT: One alternative to building a perfectly timed creature, should that prove impossible, is finding a perfectly timed creature.  It's possible to build a hallway that can only hold a creature with delay 10.  Exploiting build order, it's even possible to build it such that it rejects creatures crossing 10 tiles in 99 ticks or 101 ticks, meaning that you'd have a reasonable rate of throughput.  More, you could design a feeding chamber that (usually) permitted only one goblin from a pit into the chamber at any given time.  If you did that, all you'd have to do is pit a few hundred goblins and look every once in a while to see if throughput had stopped.
« Last Edit: August 22, 2011, 05:21:39 pm by Nil Eyeglazed »
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.
Pages: 1 [2]