Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Challenge: Dwarven RNG  (Read 1835 times)

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Challenge: Dwarven RNG
« on: August 12, 2011, 04:46:26 am »

So I was noticing that dwarven water logic is pretty complete.  Still, I noticed one missing function: the random number generator.

Why do you need a RNG?  Let's consider that you're integrating water logic with a creature based timing system.  You have a goblin with agility 1050.  Half of the time, he will cover 10 steps in 100 ticks; half of the time, he will cover 11.  You can build a path that is 10 or 11 steps long, but not 10.5 steps long.  You can't build a system that makes the path 11 steps long every 100 ticks and 10 steps long every 100 ticks, because that's begging the question; if you had a 100 tick timer, you wouldn't need the goblin based timer in the first place.  The answer?  A path that is 10 steps long 50% of the time and 11 steps long 50% of the time.  Over 100 ticks, it won't be accurate, but over 10000, it will be good.

Now, the big problem with the dwarven RNG is testing.  It's easy to assume that the 3/4 bridge/floodgate repeater provides a 50/50 of 3 or 4 water level.  But does it?  Maybe it's 3 deep 75% of the time?  66% of the time?  The ultimate test of an RNG would be a cumulative test: a read-out displaying the ratio of on to off that approaches 50% as the fort ages.

I don't know the answer.  I'm just throwing this out there as a potentially solvable logic challenge for players much more skilled than I.
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.

Silly Theory

  • Bay Watcher
    • View Profile
Re: Challenge: Dwarven RNG
« Reply #1 on: August 13, 2011, 01:12:27 am »

Whats a RNG?
Logged

CT

  • Bay Watcher
  • Gah zombies!!
    • View Profile
Re: Challenge: Dwarven RNG
« Reply #2 on: August 13, 2011, 01:15:37 am »

Whats a RNG?

  Still, I noticed one missing function: the random number generator.


Logged
No, yep. That's what I meant too. I want to come out of the theater completely fucked up for weeks.

Silly Theory

  • Bay Watcher
    • View Profile
Re: Challenge: Dwarven RNG
« Reply #3 on: August 13, 2011, 02:11:50 am »

:c
Logged

CT

  • Bay Watcher
  • Gah zombies!!
    • View Profile
Re: Challenge: Dwarven RNG
« Reply #4 on: August 13, 2011, 02:20:35 am »

:D also is your pic from when mars attacks?
Logged
No, yep. That's what I meant too. I want to come out of the theater completely fucked up for weeks.

Uristocrat

  • Bay Watcher
  • Dwarven Railgunner
    • View Profile
    • DF Wiki User Page
Re: Challenge: Dwarven RNG
« Reply #5 on: August 13, 2011, 03:54:10 am »

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.

Logged
You could have berries on the rocks and the dwarves would say it was "berry gneiss."
You should die horribly for this. And I mean that in the nicest possible way.

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: Challenge: Dwarven RNG
« Reply #6 on: August 13, 2011, 04:15:37 am »

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.
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.

Silly Theory

  • Bay Watcher
    • View Profile
Re: Challenge: Dwarven RNG
« Reply #7 on: August 13, 2011, 05:10:46 pm »

Ya, it's from Mars Attacks.

Awesome movie. Tim Burton used to be good :c
Logged

Socializator

  • Bay Watcher
    • View Profile
    • Dwarf Fortress CZ
Re: Challenge: Dwarven RNG
« Reply #8 on: August 13, 2011, 07:27:11 pm »

What about the rain? Arent the postions where whater fall completly random? It is not available all the time, for sure, but it is probably direct access to RNG :) Just use the water in the murky pools in the proper way, somehow ... let the dwarven engineers figure out how :-P
Logged
Navštivte českou Dwarf Fortress komunitu a fanpage!