Bay 12 Games Forum

Please login or register.

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

Author Topic: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock  (Read 11478 times)

Nil Eyeglazed

  • Bay Watcher
    • View Profile

{EDIT: This thread isn't really about a clock, even though it purports to be.  It's about creature logic in general.  If you're finding this on some kind of search, be aware that later posts delve into the things we'd need to make a programmable creature logic clock; the intro post describes a creature timing loop to find a creature of a certain speed, just as masturbatory indulgence in creature logic and timing effects.

If creature computing is your thing, you might want to check out my wiki user page at

http://df.magmawiki.com/index.php/User:Vasiln

I do a lot of theorizing and planning about both creature logic structures and the infrastructure needed to make them actually work on that page.
}

No water, no wind, no power?  No problem.  You can still build a clock.

{UPDATE: There is now a movie to watch this thing in action, if you so desire.  I kept it relatively short.  It's at:

http://mkv25.net/dfma/movie-2364-dostngospthechosenone }

This is what I call a creature 40-loop:

Each corner pressure plate is linked to the adjacent hatch and door.  Important: the doors must be built before the pressure plates.  It keeps the goblin moving clockwise: at any given moment, there is always one and only one path for the goblin to take.  Alternating pressure plates link to an incrementation device (don't worry, I'll show you how it works in a bit).

I call this a 40-loop because it takes exactly 40 steps to get to where you were before.  You can make this loop as big as you want, but you can only shrink it so far-- a 16 loop is the smallest you could get away with with a 10-delay goblin like Dostngosp.  16 is plenty small, though, since you can fill the whole thing with pressure plates to trigger anything you want.  You could make a perfect 40-on, 40-off spike repeater out of this same circuit, use Dostngosp to drive both the spike and the clock at the same time.  It looks simple enough, but believe me, I went through a lot of failed versions before settling on this style.

All you need is one dwarf, a shitton of rock, and a delay 10 goblin.

What's a delay 10 goblin?  It's a goblin that takes exactly 10 ticks to move one step-- never more and never less.

"Yeah, I could build a clock with a delay 10 goblin-- and if I had a million bucks, I'd be a millionaire."

That's right.  So how do we get a delay 10 goblin?  We're going to examine each goblin we get, watch it take about 3000 steps, and make sure that it never takes 9 or 11 ticks to take a step.  I figure it should take about 400 goblins before we find one that works.

Don't worry, you're not going to do it manually.  We're going to build a goblin QA device.



So the goblins get dropped into someplace (I use a mass pit, but dropping them from a bridge trap would work as well), get separated and shuffled off to the QA.  Let's start with the first part of the QA process, rule-out fast:



This one is pretty simple.  That pressure plate is linked to everything you can see.  Goblin travels left to right.  Pressure plate blocks off the hatch, so the goblin doesn't escape downstairs; it opens the doors, so the goblin can proceed (the two adjacent doors are a legacy of a previous and-gate, but I don't use the and function anymore); it opens the far door, making the goblin think he has a path; it opens the far hatch, so the goblin thinks his path is downstairs.

If the goblin has a delay of 9 or less, he reaches the space occupied by the door before it closes-- then he escapes.  Otherwise, the door closes, hatch closes, goblin re-evaluates his path, and continues forward to the rule-out slow.



So this is simple too.  The pressure plate is linked to a hatch cover and to two doors on the far end.  Yes, two doors-- one of them is open in this picture.  You'll see why.  Important: doors must be built after the pressure plate!

Goblin is pathing to the downstairs, but when he reaches the pressure plate the hatch doors close and he loses path.  No problem, because the newly opened doors ahead of him give him a new path.  He races towards them.  If he is delay 10 or faster, he reaches the second door just as it closes-- in fact, if it takes him 100 ticks to reach the far door, it closes on the exact tick he reaches it, and it gets wedged open, like you see here.  If he is even one tick slow, the door closes in his face, he waits for the hatch cover to close again, and escapes downstairs.

In case you're curious, rule-out fast and rule-out slow were both relics of a previous loop design, where it could be screwed up by certain speeds of creatures that were much slower or faster than the 10 delay I was looking for.  I left these two initial passes because it eases design-- it's wonderful to only have to consider creatures taking between 9 and 11 ticks to cross a tile, much better than having to consider every possible speed of creature.

If the goblin had the right speed, the door more towards the left is now closed, and he continues pathing down to the initialization of the main loop.



So don't get intimidated by all of the doo-dads in here.  Start with initialization chamber: goblin is drawn down by the exit, but a pressure plate opens the hatch before he gets there.  That same pressure plate opens the door entering the loop as well as the first door that the goblin will run into after entering the loop, goblin can now path to the next pressure plate.  This pressure plate opens a far door (important: build this door before the pressure plate).  Ignore the rest for right now.

The goblin's in the loop.  He paths to the far exit; the door just in front of it will close 99 ticks after he leaves the pressure plate.  He will reach the space the door occupies at tick 100.  If he crosses the 10 tiles in only 99 ticks, he's home free.  But he doesn't.

Let's continue on to the next arm.



Look at the pressure plate with the yellow line.  It's linked to a door that's currently open-- you'll see why in a second.  Important: this door must be built after the pressure plate.  It will close exactly 100 ticks after the goblin leaves that pressure plate.  If he takes 101 ticks to cross that space, it closes in his face.  If he takes 100 ticks exactly to cross that space, it closes on him (and is wedged open, as shown).

Look at the red pressure plate.  It's linked to the door as shown.  Important: this door must be built before the pressure plate.  It will close exactly 99 ticks after the goblin leaves the pressure plate.  If it takes him 100 ticks to cross that space, it closes in his face.  If it takes him fewer than 100 ticks, he escapes.

That should demonstrate the basic loop.  What about the rest of the stuff?  All of the doors on the inside of the loop are for building access only; now that the loop is finished, I could remove them.  The hatches on the outside are important because they give an escape route to a goblin that moves too slowly; the hatches in the middle of the loop arms block retrograde pathing down these escape routes for a goblin moving at the proper speed.  (Goblins move counter-clockwise in this loop.)

So far, so good.  But like I said, I expect we need about 400 goblins.  We're not going to be dropping them in individually.



So goblins get dropped down from a mass pit on to the leftmost square here.  You can make this chamber as big as you want, to accomodate as big of a mass pit as you want; you can also connect this chamber to a pit under your entrance bridge, so dropped goblins make it down here.

Goblins path through the pressure plates toward the QA process.  Each pressure plate is linked to the orthogonal hatch.  The presence of a single invader on a square thus blocks access to or past that invader's square.  A door, currently open, connects the system to the QA process; escaping goblins trigger a pressure plate that opens the door, giving entrance to the right-most invader for non-stop testing.  (If the goblin-well ever runs dry, you will need to manually open the door via a lever to get the process started again.)  Goblins that fall path back up the ramp to this chamber.

This is one of the imperfect parts of the design-- occasionally, two invaders will make it through into QA, gumming up the process.  Eventually, the system will get back to normal, but it can take a long time.  I haven't figured out exactly what's going on yet; when I do, I might be able to make it perfect.

Okay, so that's out of the way.  Next problem is that we need a lot of confidence in our invaders delay.  An invader with delay 10.01 has a 67% chance of making it through the loop once; we want a lot more confidence than that, but we don't want to sit around counting the times the invader has looped.  We're going to build a counter.

An invader with 10.01 delay has only a 9% chance of making it through the loop 6 times.  Let's build a six-count.



My goblin counters are pretty simple.  Each pressure plate is linked to all adjacent hatches.  A pathway of doors provides a route around the hatches.  These doors are triggered by alternating pressure plates; in this case, the NW pressure plate on my main QA loop is toggle1, and SE pressure plate is toggle2.  Each time the goblin loops the QA loop, the goblin in our 6-count moves forward two pressure plates.  Three alternating doors provide escape routes to the goblin-- don't worry, he'll never reach them.

There's only one problem with this-- what if the QA goblin makes it around the loop a couple of times and then fails?  The 6-count needs to be resettable.



We already have our escape reset switch to allow the next goblin into the QA (actually, it's also linked to the doors that can get wedged open in the main QA loop, to reset the system for the next goblin).  We build a little escape into the middle of our counter, gives access to it from any pressure plate, and link the doors to our reset.  When a goblin escapes the QA loop, our 6-count goblin returns to the beginning of our loop, and an ad-hoc AND gate permits access the next time a goblin runs the QA loop.

Just so you know, this 6-count loop is really sloppy.  I didn't care about timing too much.  Really, our reset ought to lead us to the first position in the loop.  All I cared about was making a really big number.

No, 6 isn't so big.  But then, 9% chance of error is too high for me.  And what if the game works such that our test invader has a 10.001 delay?  We need to test that goblin many more times than that.



This is basically the same thing-- except it has 25 cells and it's in a straight line.  In fact, it's equally sloppy.  This is my first time making these things resettable.

But rather than toggle 1 and toggle 2 being driven by the QA loop, they're driven by the 6-count loop-- at the 6th and 12th cells of the 6-count.  Once a goblin escapes from this 25-count, he triggers a trigger-once pressure plate that closes a pretty bridge on the surface, and I know that a goblin has been running around in my QA loop for about 3000 steps-- for 30,000 ticks.  Even if he can have a delay of 10.001, there's less than a 5% chance of that goblin making through my entire QA process.  (And if you're curious, when I found Dostngosp, I had him run through again, for higher confidence, and he passed again.  Odds of that happening to a 10.001 are about 0.25%.  Not 25%-- 0.25%.)

Why's it a 25 count and not a, I dunno, 12.5 count?  Mostly just because it doesn't trigger any further counters.  So every step of this matters, instead of every other step.  Every 6 steps of the 6-count triggers one step of this; every twelve, two.  We could just as easily call the 6-count a 12-count and call this a 12.5-count.  It adds up to the same thing.

What about the clock?  Look at that 6-count.  Couldn't you as easily make 3-count?  (You can.)  How long does it take a 10-delay invader to run a 40-loop?  400 ticks.  What's 400x3?  1200.  How many ticks are in a day?  1200.

Couldn't you make a 7-count?  Yup.  Couldn't you make a 4-count?  Couldn't you make a 12-count?  All of the above.  And you have week, month, and year.

In fact, there is only one problem remaining, but it's a doozy.  Attribute rust.  In fact, rust will occur in less time than it takes an invader to complete my QA process.  This is the one place where my clock requires cheating: it requires modifying goblins (and/or elves) to suffer no attribute rust.

« Last Edit: September 02, 2011, 04:37:08 am 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.

Quantumtroll

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #1 on: August 26, 2011, 05:05:07 pm »

I'm rendered absolutely speechless.  What happened, did a fey mood come over you??
Logged

Excedion

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #2 on: August 26, 2011, 05:07:18 pm »

Sweet merciful Armok. This is very impressive !!Science!!

But i pose to you a question, do you actually use the clock for any purpose? or do you just like making goblins run around endlessly?
Logged
If adamantine is perfectly rigid, as shown by having 0 strain at fracture in the raw files, then the speed of sound in the metal approaches the speed of light. Adamantine musical instruments would produce ultrasonic vibrations, and cut off the fingers of the musician.

PwndJa

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #3 on: August 26, 2011, 05:08:28 pm »

"The neckbeard is great with this one" is about all I can think right now.
Logged

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #4 on: August 26, 2011, 05:15:25 pm »

Lol, the clock does nothing :)  I had an earlier clock based on a 4-cycle pump-based repeater and the only thing I ever did with it is make a sundial.

It is actually sort of beautiful to watch invaders run the QA loop.  Let me tell you, by the time they fail, they are dizzy.  You should see them try to path out of the thing.

The neckbeard is definitely in effect these days.

In case anybody is as crazy as I am, this involved learning quite a bit about exactly how pressure plates send signals, and some of the stuff I learned flies in the face of conventional wisdom.  I've changed the wiki page on pressure plates as a result of this, and I've filmed a short movie, available at http://mkv25.net/dfma/movie-2363-timingdetails that shows the exact timing of pressure plate activation (and deactivation) on various buildings with different build orders.  It's not very entertaining, and the only way to see the weirdness is to step through it frame by frame.
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.

simonthedwarf

  • Bay Watcher
  • ¤Death¤
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #5 on: August 26, 2011, 05:20:22 pm »

Declare him a living saint! Armok's will is enacted through Nil Eyeglazed! We are not worthy!
Logged
Quote from: Syndic
Sentry towers, manned by orang-utangs./quote]

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #6 on: August 26, 2011, 06:47:57 pm »

Update:

Remember how I said the goblin feed wasn't working properly?  I think I figured it out.

I mentioned that it needed manual reset once the goblin well ran dry-- the problem was that my manual reset wasn't sending a close signal to the door, so if one made it into the QA loop before the next triggered the reset, there were two invaders in QA.

I redesigned the reset.  I decided to do it a little bit weird.  It was the first thing that came to mind.  Well, okay, it was the first thing that came to mind that would have worked.  (First I was going all crazy on binary goblin memory cells, which btw are really cool and I didn't show you one at all, to keep track of whether an invader was in QA or not, and creature logic devices to turn a lever pull into a toggle.)



See that lever?  It used to be linked to the door now linked to by the pressure plate.  Now, it links to nothing.  It's just a doo-dad to get a dwarf to path through the one-way corridor pictured.  (It's one-way because the pressure plates are triggered by citizens, so the trigger the adjacent hatches, and dwarves always go through the lever hallway left to right-- although they have no reason to go there unless I give them a pull lever task.)

Now, the pressure plate links to the door opening up QA, so it sends an automatic close task that happens before another goblin can make it through (before a path exists from the queue).  Additionally, I made another hatch-pressure plate system before the reset switch, to prevent re-entering QA after triggering the reset.  Now, I have no problems.  I just route invaders through a couple of serrated disc traps (just after the reset switch) if they manage to escape QA, and I drop them all into the mass pit.

EDIT: Btw, try not to let any trolls into your QA pipeline.

And try to avoid cats.
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.

Anathema

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #7 on: August 26, 2011, 07:00:46 pm »

Just imagine what the goblins must think of this. While out raiding and murdering and just generally being goblins, they are captured in traps, dumped unharmed into the bowls of a mysterious machine, and then must race through in circles while being tested by unseen observers. Finally, sooner or later, every goblin fails - tired, dizzy, confused, he blinks into the sunlight as he is unceremoniously released to the wild, returning to his brethren with another mystifying tale of the testing machine. Every goblin but one, that is - blessed Dostngosp, who was chosen by the Machine and ascended to run the Divine Clock in the Sky. Religions have been founded on far less.
Logged
The good news is that ghosts die of old age.

Noodz

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #8 on: August 26, 2011, 07:07:40 pm »

Toasting in an epic bread. This definitely qualifies as a stupid dwarf trick.

@Anathema: you make it sound like the gobbos were abducted by aliens.
Logged

Gamerlord

  • Bay Watcher
  • Novice GM
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #9 on: August 26, 2011, 07:27:20 pm »

Can... can we do this with elves?

TurkeyXIII

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #10 on: August 26, 2011, 08:41:31 pm »

I heartily approve your use of microcline.
Logged
A medium-sized bird with a distinctive fleshy wattle that hangs from the underside of the beak, and a fleshy protuberance that hangs from the top of its beak called a snood.

monk12

  • Bay Watcher
  • Sorry, I AM a coyote
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #11 on: August 26, 2011, 08:55:34 pm »

This is the greatest thing to pass onto the forums in quite some time. Legendary, even. *cough*

Unrelated, this isn't Lanterndark, is it?

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #12 on: August 26, 2011, 10:43:37 pm »

1) You can do this with elves.  Actually, they were some of my first test subjects.

2) It's not microcline.  Because I wanted to explore these mechanics without having to worry about anything else, I made a cheat world.  I know, that cheapens it a little bit.  If it's any consolation, I needed invaders to make it work, and I needed to maintain constant map edge access to maintain proper pathing.  Of course, that doesn't much matter when you've got 50 cage traps.  I need them alive; preferably, unwounded.  The design can be done with any stone, though, or with any mechanism quality metal.  All you need is a mason/blacksmith and a mechanic.

3) It's not Lanterndark.  It would have been, but Lanterndark is suffering frame-rate hell.  10 fps with everything disabled, and the map I used for this device has 700-some mechanisms in use-- not that all of them are necessary, but most are.  I might go back to the Lanterndark story, but if I do, it's going to mean forgetting the actual game and just making it up.


I'll try and get a movie of the whole thing in action later.  Somebody else might find watching those invaders as entrancing as I do....
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.

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: A still mountain, a dry dwarf, and about 400 goblins: The Invader Clock
« Reply #13 on: August 26, 2011, 11:55:13 pm »

I just want to say that this is amazing and I whole-heartedly vote for making it Legendary. Also @Anathema that's awesome, now we just need someone to harness this power and make a doomsday clock that counts down the years to the release of all of the accumulated FUN that can be harnesses in the 50 years of fortress playtime.
Real spoilers
Spoiler (click to show/hide)
« Last Edit: August 27, 2011, 12:39:56 am by i2amroy »
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Nil Eyeglazed

  • Bay Watcher
    • View Profile
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 3 4