So I was noticing that dwarven water logic is pretty complete. Still, I noticed one missing function: the random number generator.
Well, you can only get pseudo-random numbers out of a deterministic device like a computer program, but that said, build your pseudo-random number generator out of a chained animal surrounded by pressure plates. Use each plate as a means to input a bit or three of entropy which you mix into your entropy pool and use as needed. Note that you will likely need the entire dwarven CPU that someone made to accomplish all of this, but you can mix it in there properly.
That's a pretty good idea. You won't need a whole dwarven CPU, because if you can make it a 0.5, you can run ands on other RNGs to make any exponent of 2. Unless you consider an and to require a dwarven CPU.... Certainly, conversion of random bits to something like a random integer between 1 and 3 inclusive is complicated and imperfect. But you can make a version of it for that too-- can take advantage of at least a 1/9, depending on how staircases interact with restraints, maybe more, and 1/2 through 1/5 can get you to perfect decimal values, which are probably all you'd need. At least I think so. Don't hold me to that.
The only problem is if it's really random-- or pseudorandom, if you'd prefer reserving the term for quantum mechanics. For instance, pets path to masters, and if your master is typically on one side and not the other, you won't get a good distribution of values (you'll get 90% true, 10% false, for instance). Goblins are worse, likely leading to 100% true, 0% false (or vice versa, of course). Maybe untamed wildlife would work? I'm thinking you might have a slow poll of the function, and the risk is that they'll only ever attempt to path to surface (or cavern) tiles. That can be dealt with via placement, but it's very limiting. Worse, I suppose, would be pathing to any visible, accessible ground tile-- you'd need to build completely symmetrically to take advantage, and probably lose distribution the instant you locked a door.