Bay 12 Games Forum

Please login or register.

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

Author Topic: Programmable Dwarven Computer. With Minecarts.  (Read 16627 times)

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #15 on: January 22, 2015, 08:25:40 pm »

So you're using a game played on a real computer to make an in-game analog computer?  The very idea of this just makes my head hurt.  It's like fiddling around on a graphing calculator to create an abacus.

Actually, this is a digital computer. Analog computing would be much harder, and I dont think there is a system (in the game) able to pull it off.  It may not be a binary computer, (It uses more states than just 2 in the tape programming) but it is still digital.

Analog computing is ... something else entirely.
Logged

Larix

  • Bay Watcher
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #16 on: January 23, 2015, 10:19:03 am »

I'm not sure anything within the game can be considered analogue - after all, it's all simulated in a _digital_ computer.
One thing that's somewhat close to analogue functions might be the resultant speed of a minecart collision. To the best of my knowledge, it's simple three-variable algebra:
v(out) = v(in) * mass (in) / mass (out)

Preferably implemented by pushing a standing cart. Outgoing speed in that case is capped at incoming speed. Obviously, using the resulting speed as basis for further computations other than simply pushing more carts is kind of tricky. You might just want to measure whether or not it reaches/exceeds a particular speed, i.e. derive a digital result: http://mkv25.net/dfma/movie-2662-advancedsignallesscalculator

The notion of "analogue" computer may have been caused by the use of simulated mechanics as medium; of course you're right - the distinction is a different one. A mechanical computer can be logically digital and electronic computers can be analogue. (Can't even mechanical cash registers be considered digital calculators, since they have discrete states for each digit? I might be stretching the definition beyond breaking point...)
Logged

SirQuiamus

  • Bay Watcher
  • Keine Experimente!
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #17 on: January 23, 2015, 11:47:42 am »

The notion of "analogue" computer may have been caused by the use of simulated mechanics as medium; of course you're right - the distinction is a different one. A mechanical computer can be logically digital and electronic computers can be analogue. (Can't even mechanical cash registers be considered digital calculators, since they have discrete states for each digit? I might be stretching the definition beyond breaking point...)

Since popular histories of computing tend to start with the advent of digital computers, I had no idea that analogue electronic computers were an actual thing that was widely used in the past -- even in the pre-war era, that is. The EC-1 looks like an analogue synthesizer, and that's basically what it is: simple equipment for shaping and comparing continuous signals.

EDIT: By the way, Wikipedia says that the Z3 utilized some 2000 relays. I wonder how that figure compares with the minimum of 2000 mechanisms envisioned by wierd. 
« Last Edit: January 23, 2015, 12:52:36 pm by surqimus »
Logged

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #18 on: January 23, 2015, 01:17:23 pm »

I would be interested in seeing a transistorized version of the Z3 actually.  A magnetic reed relay switch is very similar (logically) to a transistor. A transistorized version would knock the socks off the mechanical Z3. (We have ICs with dozens of transistors baked inside them as discrete electronic components these days. A few hundred such ICs on a very large breadboard, and a transistorized Z3 can be yours.)

The problem is that a gear assembly does not really model a transistor all by itself.  This means that a DF implementation of the Z3 would consume more than 2000 mechanisms. (you have to account that toady insists mechanisms be incorporated in every sensory device, and every remote activated device-- and that doesnt count the mechanisms incorporated into power delivery and power generation.)

The Z3, implemented in the closest analogy possible in DF, would consume upwards of 6000 mechanisms. Probably a lot more than that actually. (It would likely be slower than Larix's computer too. His is very tightly optimized for the DF simulation.)

Logged

tonnot98

  • Bay Watcher
  • Damp stone located.
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #19 on: January 23, 2015, 02:33:10 pm »

So you're using a game played on a real computer to make an in-game analog computer?  The very idea of this just makes my head hurt.  It's like fiddling around on a graphing calculator to create an abacus.

I think the true and secret goal of Larix is to rewrite DF into DF itself... Eventually, that will lead to a DF spiral.
Anyway, great job here !
Then people would host succession games for the dwarf fortresses within the dwarf fortress.
Logged
Not sure if dying of old age is an honor or a shame for weaponmasters. On the one hand, it means they never got the opportunity to die in glorious battle. On the other hand, it means nothing could beat them in glorious battle.
Meow.

Badger Storm

  • Bay Watcher
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #20 on: January 23, 2015, 03:03:21 pm »

I guess analog was not the best word.  I meant computer as in a tangible object with a screen and keyboard and everything.  As an example of what I mean, you have a calculator on your OS, probably.  Why, then, would you rig up a bunch of dwarven machinery to create one in the game?  Is it, in a sense, similar to those Lego robotics kits where you could make a little carousel or swing set from the Lego parts?
Logged

SirQuiamus

  • Bay Watcher
  • Keine Experimente!
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #21 on: January 23, 2015, 04:00:55 pm »

I want to encourage Larix to continue his efforts, as these kinds of diversions give a very good education in computational theory, and greatly hone logic skills.
I guess analog was not the best word.  I meant computer as in a tangible object with a screen and keyboard and everything.  As an example of what I mean, you have a calculator on your OS, probably.  Why, then, would you rig up a bunch of dwarven machinery to create one in the game?  Is it, in a sense, similar to those Lego robotics kits where you could make a little carousel or swing set from the Lego parts?
 
Basically, yes, I guess. In every serious engineering project, building a working model of the device (using Lego parts, Play-Doh, etc.) is an indispensable part of the workflow: Even highly experienced engineers need to test their designs within a controlled setting before putting them into practice, and DF is the optimal environment for simulating the non-Newtonian minecart physics Larix's computer is based on. The simulation phase of the project has been eminently successful, and it is very likely that the design can soon be implemented in our standard reality.   
« Last Edit: January 24, 2015, 04:43:57 am by surqimus »
Logged

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #22 on: January 24, 2015, 12:49:03 pm »

dont get me wrong here--  Larix's computer probably would not work well in the real universe. However, the logic training and head scratching that this project puts him through would allow him to make highly optimized systems tailored for the real world just as they hone skills to make computers optimized for DF.

That is to say, once he has a firm grasp of rolling his own processors, there is little to stop him from getting an FPGA, and implementing new CPUs on it. Designing good processors is a rare talent, and I want to encourage it.

DF costs nothing, and provides a sandbox that is capable of supporting this kind of learning. It's a good place to build the skills before sinking the cash into an FPGA.

(an FPGA is a Feild programmable gate array. It's a special kind of chip that can be programmed to implement the hardware of other kinds of chip, including cpus. They can be wiped and reprogrammed many times. They are used for CPU and other logic chip prototyping. They can be a little expensive, and arent fun for everyone. However, I think that Larix would probably enjoy having one.)

it is entirely possible that larix could implement his minecart logic computer on an FPGA, and see how well it performs outside of DF, but it would be analogous at best. (the minecart computer makes use of more than 2 states in its logic. FPGAs are geared toward binary logic, which means he would have to rethink the cpu a bit. additionally, his "timerless" design would not work out of the box either. It exploits DF centric behaviors. The basic principles of the computer could still be implemented though, as could the instruction set, word type, etc.)
Logged

Larix

  • Bay Watcher
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #23 on: January 24, 2015, 08:04:05 pm »

Fundamentally, building a computer in DF is a deeply impractical, playful exercise. It can double as a kind of self-education in logic machines, though. Building a computer from lego blocks is a pretty apt comparison. Some people have actually done such things.

I think it's an intriguing challenge exactly because the core component of DF signal-based logic, the mechanism link, is an utterly primitive on/off switch and the actual flavour of logic you use plays such a big role. Fluid logic bears some similarity with transistors, routing power through gear assemblies is closer to electromechanic relays, and i don't think there's a real-world computing equivalent for minecarts.

I find going from constructing isolated logic gates and single-purpose machines to a computer was a huge leap. Building a bunch of memory cells and being quite happy to see them work is one thing, integrating a few dozen of them into registers that can be adressed to exchange data with other registers or a "bus", in a meaningful way, is very different.

The computer as is can of course not be implemented in real-world items - we don't have perpetual motion ;) Much of the timing logic and design specifics depend on the peculiarities of DF's minecarts. Hmyeah, the instruction set and the logical architecture shouldn't be really hard to implement in real-world hardware, with some adaptations, but you'd probably want to run it off a system clock to preserve sanity; while consciously using delays of the hardware opens some paths for clever optimisation, completely replacing the system clock with delay lines doesn't sound like such a great design choice.
Logged

Csponge

  • Bay Watcher
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #24 on: January 24, 2015, 10:46:11 pm »

How does the dwarfputer compare to minecraft redstone computers? I realise MC has evolved to the point of having 2 color displays and such, though their processing power is quite limited. The `fastest` MC computer has been noted to take several minutes to compute a set of 31 X,Y coordinates, as an example.

The `fastest`mc pc.
https://www.youtube.com/watch?v=X6UI1RNovro
Logged

Larix

  • Bay Watcher
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #25 on: January 25, 2015, 07:59:48 am »

Minecraft computers are typically orders of magnitude faster and more powerful than DF computers. DF encourages unusual approaches towards computation, to the point that conventional real-world designs tend to be much less useful and practical.

The speed this computer manages is around 400 game steps per operation, and the operations are very, very basic. At ~20 fps, that means roughly 20 seconds real-time for each instruction. I built an ultra-primitive model processor (can only move data, increment/decrement, leftshift, bitwise XOR/NXOR/AND/NAND and conditional jump, mostly only with one register pair per operation) going for maximum processing speed and reached a blistering one instruction per 120 steps, close to the theoretical signal-processing max of one per 100; anything less than 105 is likely purely theoretical, because it'd require signal generation delays of less than five steps per full operation and getting the build order of all components (plates, gears, rollers, minecarts, pumps, everything) just right.
http://dwarffortresswiki.org/index.php/User:Larix#Maple_6.2F6_Programmable_Computer

Spoiler: Long, speculative (click to show/hide)
« Last Edit: January 25, 2015, 01:35:29 pm by Larix »
Logged

NomeQueEuLembro

  • Bay Watcher
  • [COFFE_DEPENDENT]
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #26 on: January 25, 2015, 09:05:51 am »

Awesome.
I'm an electronics student and I can't even understand that. (granted I don't really pay attention on digital electronics class, but yet).

Congratulations, Sir. You're some sort of a genius.
Logged
Likes weremammoths for it's awesomeness. Also, got a trumpet that menaces with spikes of sheep wool.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #27 on: January 25, 2015, 02:07:28 pm »

Huh, I use a tile+graphics set so my first parsing of the default stuff was "by Armok that is a lot of blood", then I realized it was probably hematite veins, which is good, a minecart computer powered by blood is getting a little too close to the Laundry Files universe for my taste.
Logged

Larix

  • Bay Watcher
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #28 on: January 27, 2015, 03:00:58 pm »

To complete the documentation, here are the full program listings (in glorious binary machine code) of the programs i've run on the minecart computer. The code reference, if necessary, is here, the spoilered part.

I'd be very appreciative if someone with actual computing knowledge could come up with suggestions for things a DF computer could do, because this is pretty much the limit of my imagination (and one of the reasons why i didn't go for a bigger machine, since this one was entirely sufficient for the programs i could come up with).

Obvious limitations of DF computers that might impose some limits on programs that can actually be made:
- very limited input and output options: direct input of signals comes through levers and pressure plates, which are pretty bad at generating interesting data apart from player-controlled or pre-computed inputs. Graphical output is largely limited to opening and closing buildings (excessively FPS-unfriendly and extremely link-hungry - look at Bloodbeard's impressive project to see just how massive an alphabetical keyboard gets; in the published version, it could display 32 letters of 3x5 pixels using about 35.000 mechanisms; FPS were decent due to various optimisations like needless dwarfs and material-making reactions, and an older game version).
- very low operation speed: theoretically, ten operations per dwarf day and maybe one per real-time second would be possible. Four operations per dwarf day and one in five seconds real-time are more realistic. A program that takes a thousand steps to complete would be taxing, five thousand would definitely be too long.
- bits are very expensive, especially registers and RAM. Programs which require tons of read-/writeable data are not a good idea (notable amounts of code aren't too bad if runtime re-coding is very limited).
- much of the fancier stuff like parallel processing and variable-length instructions haven't been shown in DF computers yet; don't expect too much at once.


« Last Edit: April 11, 2015, 12:55:34 pm by Larix »
Logged

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: Programmable Dwarven Computer. With Minecarts.
« Reply #29 on: January 27, 2015, 08:03:54 pm »

One interesting application could be automatic drawbridges that open only twice per trade season. (or once, with exit route through cavern layer?)

Use the "Were creature reliable month signal generator" to have a reliable reference clock to sync the computer to the game's calendar, and have the computer evaluate how many times the signal has been hit, then open the gate for a pre-programmed interval to allow dwarves in before shutting the gates-- waiting another preprogrammed interval before opening the gates to let them out-- then shutting and waiting for the next clock signal from the werebeast.

The computer would spend the vast majority of its time sitting idle. It would only trigger after its accumulators hit the magic values.

Fully automated goblin christmas could be another possible end goal.  The computer monitors several key sensors through the goblin christmas holiday fun-ride, along with the above-mentioned werebeast clock signal-- and exploits pathing behavior to get goblins to enter the funride at the correct yearly intervals, then monitors their progress, and reacts accordingly. Kills the goblins/trolls/demons, then mechanically separates them in an automated processing system. There werebeast in the werebeast clock signal generator could be the pathing target inside the fortress. (Keep the werebeast on a chain.) In fact, both operations could be part of the same program.

You would only need a handful of sensors, and the delay of sensor trigger to computer activation (and subsequent countermeasures) could be accounted for with good fun-ride design. Goblins and trolls dont teleport-- so we have some granularity between passing checkpoint A and passing checkpoint B that allows for the computer to respond.

Again, there's also the possibility of using the computer for additive CNC construction of a megaproject, like a detailed statue cast out of obsidian.

Create a gantry at the highest level of a very large retainer wall with a drain chute that goes off the side of the embark. Along the inside of this wall, put pressure plates that check water level. (One plate per level is sufficient. Just put it in the extreme corner of the tank.) The computer controls the filling and draining of the tank with water to assure an appropriate "working level" for the reaction process, then builds the structure by controlled dropping of magma blobs from the gantry (or floorhatch matrix) at the top. A gantry with a dropper minecart should ensure suitable "droplets" are dropped, and not "streams", like a floor hatch would give.  Designing the gantry itself would be part of the fun. But once built...

Flood, add, flood, add.. .. .. drain, done.

Such construction could proceed even during sieges or other daily annoyances, as long as the computer itself does not get damaged.  A 3D computer controlled voxel printer, right there in DF, building the actual fortress proper. (The retainer wall and the gantry could be removed with controlled deconstructions of support later.)



Logged
Pages: 1 [2] 3 4