My current fortress defenses consist of upright spikes that can be raised and lowered.
It's easy enough to use a repeater, but what's the fun in that? Although you
can- theoretically- design a repeater with a period above any number you care to choose, they're all basically working the same way, and they all repeat. Really, that just isn't any fun. Sooner or later, even if it's a decade from now, as the invaders get smarter, Toady's going to implement goblins that might have a shot at predicting the actions of a repeater-run upright spike system. And then, what will you do?
Fear not, dwarflings, I have the answer!
There are other pseudorandom number generators out there, I believe. There's at least one I know of, but it's pretty complex. I can't remember who designed it, but if I recall correctly you put a whole line of waterwheels under a dwarf-made waterfall, so that some of them had flow, and others didn't, and it changed every frame.
This RNG (PRNG?) is simpler.
First, you build...a repeater! There are many designs you could probably adapt if you so felt, but the one I would use is the pump-based repeater, which is at the bottom of the page
here. Start it up and watch it grow.
Note that that repeater repeats every 400 steps, and goblins simply can't move fast enough to avoid upright spikes controlled by such a repeater. But no true dwarf attacks a dangerous mechanical project of limited purpose by making a merely adequate solution.
This is the gear setup:
☼
☼☼☼=====
☼☼
☼
where the ☼'s are gears, and the ====represents the power train going in. With a little ingenuity, you can make a separate axle traveling from each gear.
Each axle- and note, you'll have to input a crapload more power than 62 to keep this baby going, but I promise you it'll be worth it- will travel to a pump. Each pump draws from an unlimited supply of water. Here's how it should work, with a cross-section of a multi-Z level diagram: (+= floor, %%=pump, 0= wall, 7=unlimited source of water tile)
%% %%
70 07
+0 0+
0 0
0 0
0++++++++++++++++++++++++++0
The pumps- there's more than one- pump water out of the water source and into a big chamber.
Now, you should find a random number generator-
www.random.org is a pretty good one- to generate your key. Let's say we want a 7 by 7 chamber. We might line the walls with 3 pumps on each side. Then, we should put a pressure plate triggered by water on each of the floor spaces in the chamber. What we want, then, is to generate, in some fashion, a 49-digit number in base 8. In addition, this 49-digit number must contain no 0s- only 1 through 7. You can also get a 49-digit number in base 7, but you can't convert from base 10 to base 7 on your desktop calculator (I use Windows; dunno about Macs), while it's easy to convert from 10 to 8. It doesn't really matter how you do this, but for maximum effectiveness, do it in random or pseudorandom fashion.
Now, take that 49-digit number and write it in 7 strings of 7 digits each. I generated such a number:
3173472
2652346
4164762
1456455
2246376
7264136
2525727
This is the water depth you're assigning to each pressure plate. Now, assign each pressure plate to an upright spike trap- or anything else you need an RNG for, including a dwarfputer. Oh yes. You see now why this is much simpler and more useful than the waterwheel design? It may be a good policy to include some open floor hatches, else you'll get a big tub of 7/7 water before long. In any case, what you'll find is that you have an upright spike pattern that doesn't repeat. It isn't completely random, of course, but it is very close to it, and it's random enough for almost any purpose you might need. If it isn't quite random enough, this isn't a hard and fast design- you can expand it to be as big and as random as you need.