Bay 12 Games Forum

Dwarf Fortress => DF Dwarf Mode Discussion => Topic started by: Sphalerite on October 28, 2010, 01:42:03 pm

Title: Game of Life dwarfputing megaproject
Post by: Sphalerite on October 28, 2010, 01:42:03 pm
For the last few months, I've been building a megaproject which is an implementation of Conway's Game of Life in a dwarf fortress mechanical computer.  It is nearly finished.  This is how it works.

Theory
Spoiler (click to show/hide)

The mechanism
Spoiler (click to show/hide)

Sequence of operations
Spoiler (click to show/hide)

The Fortress
Spoiler (click to show/hide)

Movie of the display grid as the calculation runs:
http://mkv25.net/dfma/movie-2278-gloveflier-gameoflifedemo

Map file: 
http://mkv25.net/dfma/map-9792-gloveflier

Save folder: 
http://dffd.wimbli.com/file.php?id=3346
Title: Re: Game of Life dwarfputing megaproject
Post by: veok on October 28, 2010, 01:59:56 pm
You've won dwarf fortress.
Title: Re: Game of Life dwarfputing megaproject
Post by: DukeOfVandals on October 28, 2010, 02:01:54 pm
You've won dwarf fortress.
Seriously.
Title: Re: Game of Life dwarfputing megaproject
Post by: Dariush on October 28, 2010, 02:02:17 pm
You've won dwarf fortress.
Seriously.
No kidding.
Title: Re: Game of Life dwarfputing megaproject
Post by: The Merchant Of Menace on October 28, 2010, 02:05:51 pm
Awesome, now modify it to work under other rulesets than Conway's game.
Title: Re: Game of Life dwarfputing megaproject
Post by: Lormax on October 28, 2010, 02:06:57 pm
When I first read the subject, I thought it was the Milton Bradley game :)  Very awesome though.

Title: Re: Game of Life dwarfputing megaproject
Post by: Fayrik on October 28, 2010, 02:15:20 pm
This is fantastic.
Can't wait to see the final version!

But, aparently there's a low FPS? Have you tried deleting every creature that isn't directly involved by means of a tool like Runesmith? It could just be that those donkeys that're getting trapped up the top there are trying to move and causing some lag. (I know that the way DF deals with deaths means that unless you hack these things out, their bodies are gunna stick to the unit's list like glue.)
Title: Re: Game of Life dwarfputing megaproject
Post by: Dwarf on October 28, 2010, 02:18:14 pm
Have you attempted making a turing machine which would run Dwarf Fortress?
Title: Re: Game of Life dwarfputing megaproject
Post by: Sphalerite on October 28, 2010, 02:21:23 pm
I suspect that the low FPS might have more to do with 145 windmills and all the pumps and gears they're driving.  But I didn't even know that there were phantom animals stuck in the edge wall bridges till I generated a Stonesense screenshot.  I'll try editing those out, or maybe just lowering and raising all the edge bridges to crush them.

I also have a fair number of cows and elephants in the food production section, but they're all either chained or caged.  No other animals.  There are also a whole bunch of forgotten beasts wandering the sealed-off caverns who got in before I turned invaders off.  Can Runesmith delete forgotten beasts?
Title: Re: Game of Life dwarfputing megaproject
Post by: Johnfalcon99977 on October 28, 2010, 03:23:33 pm
I suspect that the low FPS might have more to do with 145 windmills and all the pumps and gears they're driving.  But I didn't even know that there were phantom animals stuck in the edge wall bridges till I generated a Stonesense screenshot.  I'll try editing those out, or maybe just lowering and raising all the edge bridges to crush them.

I also have a fair number of cows and elephants in the food production section, but they're all either chained or caged.  No other animals.  There are also a whole bunch of forgotten beasts wandering the sealed-off caverns who got in before I turned invaders off.  Can Runesmith delete forgotten beasts?

Yes. Just click the GENOCIDE button. Its my favorite. :)
Title: Re: Game of Life dwarfputing megaproject
Post by: Vicid on October 28, 2010, 03:25:57 pm
Should I go to college or try to be a cop?
Title: Re: Game of Life dwarfputing megaproject
Post by: Lormax on October 28, 2010, 03:41:54 pm
Both.  A recruit with a degree will go places.
Title: Re: Game of Life dwarfputing megaproject
Post by: KillerClowns on October 28, 2010, 04:27:51 pm
You've won dwarf fortress.
Seriously.
No kidding.
Another nod of agreement to this.  Wow.
Title: Re: Game of Life dwarfputing megaproject
Post by: plarf on October 28, 2010, 04:31:25 pm
+1 for making me go read about Conway's Game of Life.
Title: Re: Game of Life dwarfputing megaproject
Post by: Rolan7 on October 28, 2010, 04:43:09 pm
Amazing!
And over 9000 mechanisms, haha.  That must have been rough.  Good job, both with the theory and the execution!
Title: Re: Game of Life dwarfputing megaproject
Post by: Dwarf on October 28, 2010, 04:45:06 pm
OVER 9000?!
Title: Re: Game of Life dwarfputing megaproject
Post by: Xerillum on October 28, 2010, 08:07:17 pm
Oh my god... That is the most win thing I have ever seen in DF
Title: Re: Game of Life dwarfputing megaproject
Post by: Arkenstone on October 28, 2010, 10:29:54 pm
Hm...  I've been wondering how hard it would be to code some solid-state transistors into DF -essentially have a 3x3 workshop where the center tile of each side serves as input/output.  If we could get toady to do something like ths (and it gave better FPS) how much do you think it would bulk your device?

PS:  lol, normaly solid state reduces bulk in exchange for decreased efficiency (more heat) but in this case it would be the other way around.
Title: Re: Game of Life dwarfputing megaproject
Post by: truckman1 on October 28, 2010, 11:14:30 pm
I think the only true way to REALLY win dwarf fortress would be to make a dwarfputer capable of playing Dwarf Fortress. Or a Dwarfputer that's self-aware. But this is damn close
Title: Re: Game of Life dwarfputing megaproject
Post by: garfield751 on October 29, 2010, 12:25:17 am
this is simply amazing that you managed to achieve this much awesome in a 2x2 embark
Title: Re: Game of Life dwarfputing megaproject
Post by: vogonpoet on October 29, 2010, 05:03:34 am
Awesome. As a keen ADOM herbalist - I love me some moss and some morgia - I have so been waiting for someone to do this, so that I might praise their name.

A Game of Life simulation running inside a simulation game. Holy Shit.
 
Sphalerite, like Quantum Sawdust and a few others before you, you have indeed won Dwarf Fortress.
Congrats.
Title: Re: Game of Life dwarfputing megaproject
Post by: Kurouma on October 29, 2010, 06:15:23 am
The first programming language to be written on a Dwarfputer will be called...drumroll...
Spoiler (click to show/hide)
Title: Re: Game of Life dwarfputing megaproject
Post by: Eugenitor on October 29, 2010, 06:16:47 am
Holy shit.
Title: Re: Game of Life dwarfputing megaproject
Post by: Jordrake on October 29, 2010, 07:01:00 am
Next time my friend and I get into a Dwarf Fortress v Minecraft debate, I'm gonna drop this on him. And he will lose.
Title: Re: Game of Life dwarfputing megaproject
Post by: Sphalerite on October 29, 2010, 07:46:44 am
Hm...  I've been wondering how hard it would be to code some solid-state transistors into DF -essentially have a 3x3 workshop where the center tile of each side serves as input/output.  If we could get toady to do something like ths (and it gave better FPS) how much do you think it would bulk your device?
Interesting question.  It would probably make it a lot larger.  Each cell is performing some pretty complex logic, counting the number of cells which are 'alive' and pumping water if less than a certain number are.  To perform that with transistor logic I'd have to build some kind of 9-input binary adder, then subtract the threshold number from it and look for a carry.  The way mechanical power works in DF makes it really easy to perform the check the way I'm doing it, I wouldn't even attempted this project if I had to do it all with water logic gates.

Last night while running some test patterns I discovered that cells would sometimes fail to switch on if multiple other cells near them were changing state at the same time.  I traced this to some oddness in how DF handles flowing water.  It seems that falling and flowing water in DF is somewhat random, and I didn't leave enough time in the sequencing between when the second bridge closes and when the transfer gates open.  Pressure plates in some cells were being triggered before water had started transferring out of temporary storage cells, and under the right conditions this could cause the pumps to activate prematurely and pull enough water out of the temporary storage cell to cause the cell not to get enough water to become 'alive'.  I can fix this by adding another stage into the sequencer, making a full device cycle 707 steps long instead of 606.  Once that's done and tested I'll put up a map archive and save files.  I should be able to do that this weekend.
Title: Re: Game of Life dwarfputing megaproject
Post by: Jong on October 29, 2010, 06:30:09 pm
Well done! I was thinking of attempting this next, but looks like I was beaten to it :P

I think your 5x5x5 unit cell could be the smallest possible, which is great! I think it's a shame though that it needs to be built on the surface. Certainly waterwheels could be substituted with some minor modifications, which would make it significantly bigger.

Have you considered any less space efficient designs that don't use floodgates and bridges? Or that require fewer steps to run? Or fluid conserving designs? Since there are so many z-levels in every map now, space is rarely in short supply, so speedier designs could be more optimal. I believe water flows to be the biggest FPS hog, rather than items.
Title: Re: Game of Life dwarfputing megaproject
Post by: Silent_Thunder on October 29, 2010, 08:33:24 pm
Oh god, I want this save. Or at least a video. Either way this needs to be shared in the name of !!science!!.
Title: Re: Game of Life dwarfputing megaproject
Post by: Sphalerite on October 29, 2010, 10:23:18 pm
I think your 5x5x5 unit cell could be the smallest possible, which is great!

Actually, my original design sketches were for a 4X5X5 cell, one tile narrower than this design, but that design didn't have any provision for access stairs from below.  The dwarves would hace had to walk all the way to the side of the map and up stairs going around the array, then down from overhead walkways to work on it.  5X5X5 let me give each cell its own access stairway,  and also made drainage of excess water from the temporary register easier.

Quote
I think it's a shame though that it needs to be built on the surface. Certainly waterwheels could be substituted with some minor modifications, which would make it significantly bigger.

I considered a waterwheel-based design.  Waterwheels would have given me 60 more units of power in each cell, which would have required 12 more dummy load gears in each cell if I used the same type of mechanical logic.  Could have been done, but with a lot more parts required.  Ultimately I chose the simplest and easiest to build design.

Quote
Have you considered any less space efficient designs that don't use floodgates and bridges? Or that require fewer steps to run? Or fluid conserving designs? Since there are so many z-levels in every map now, space is rarely in short supply, so speedier designs could be more optimal. I believe water flows to be the biggest FPS hog, rather than items.

One thing I could do to speed the mechanism up is perform the overpopulation check and underpopulation check at the same time.  My design uses the same windmill/gear/pump assembly to perform both checks, with the bridges and mode switch gear reconfiguring the device between steps.  If both tests were performed at once the machine would run faster, but would take about twice the space and require about twice as many parts per cell.  I also considered a fluid-conserving design, where water was shunted back and forth between two storage cells to denote if a particular cell in the grid was 'alive' or 'dead'.  Again, this design was chosen for simplicity of construction.  In a 8X16 grid I have to build 128 individual cells, so making each cell as simple as possible was the most important design goal.

Just in the process of building this I came up with several ways the design could be improved, but this was such an insanely time-consuming megaproject to build that I'm not going to attempt anything similar anytime soon.
Oh god, I want this save. Or at least a video. Either way this needs to be shared in the name of !!science!!.
Soon.  A little bit of final testing, a few finishing touches to put on it, and I will upload a save, map archive, and movies.
Title: Re: Game of Life dwarfputing megaproject
Post by: The Merchant Of Menace on October 30, 2010, 02:45:45 am
Hehe, and then we shall all discover new evolution patterns and become famous.
Title: Re: Game of Life dwarfputing megaproject
Post by: lordnincompoop on October 30, 2010, 02:48:22 am
Dwarf Fortress (or at least Pong) in Dwarf Fortress feels close at hand now.
Title: Re: Game of Life dwarfputing megaproject
Post by: Dwarf on October 30, 2010, 04:53:40 am
Next time my friend and I get into a Dwarf Fortress v Minecraft debate, I'm gonna drop this on him. And he will lose.

Well, Minecraft may not have a Conwayian Game of Life, but a 16 bit ALU. (http://boingboing.net/2010/09/28/working-computer-mad.html)
I'm not saying anyone is better though :P
Title: Re: Game of Life dwarfputing megaproject
Post by: lordnincompoop on October 30, 2010, 06:08:13 am
I enjoy both Minecraft and DF. They are fun in different ways.
Title: Re: Game of Life dwarfputing megaproject
Post by: Rose on October 30, 2010, 06:29:37 am
I tip my hat to you, good sir.
Title: Re: Game of Life dwarfputing megaproject
Post by: Urist Imiknorris on October 30, 2010, 11:05:27 am
Dwarf Fortress (or at least Pong) in Dwarf Fortress feels close at hand now.

Virtual virtual chess?
Title: Re: Game of Life dwarfputing megaproject
Post by: Astramancer on October 30, 2010, 04:19:19 pm
Do you think you could make a quickfort template for the cell(s)?
Title: Re: Game of Life dwarfputing megaproject
Post by: Fayrik on October 30, 2010, 04:24:40 pm
Dwarf Fortress (or at least Pong) in Dwarf Fortress feels close at hand now.

Virtual virtual chess?
Conway's Game of Game of Game of Game of life?
Title: Re: Game of Life dwarfputing megaproject
Post by: Sphalerite on October 30, 2010, 08:25:16 pm
And it's done.  Map file, save folder, and example movie of the thing in operation are uploaded, links are in the OP.  The computing grid seems to be working stably now, although I have yet to let it run for more than 4 complete cycles in constant-running mode.  The rest of the fortress is finished and surviving just about attention-free on its own.  Pull the yellow lever on level 146 to start the sequencer.
Title: Re: Game of Life dwarfputing megaproject
Post by: Fuco on November 02, 2010, 08:33:16 am
Next time my friend and I get into a Dwarf Fortress v Minecraft debate, I'm gonna drop this on him. And he will lose.
Minecraft is capable of computation: http://www.youtube.com/watch?v=LGkkyKZVzug

Edit: someone beat me to it :(
Title: Re: Game of Life dwarfputing megaproject
Post by: Sphalerite on November 02, 2010, 09:33:40 am
Minecraft has redstone, and redstone torches, which basically gives you electricity, electric power sources, and easy-to-build transistors.  This makes certain computational functions a lot easier, since you don't need to mess around with pumps and pressure plates and mechanical power.  You can just build logic gates directly.  On the other hand, you're limited to on/off digital signals only.  The way mechanical power works in Dwarf Fortress makes it possible to hold and compare analog values, which is how I'm doing the "greater than four neighbors/less than two neighbors" checks with only a handful of gears.  I expect that the DF mechanism takes up a lot less space than the equivalent Minecraft circuit for this function.

The main disadvantage I have seen in Minecraft (and I haven't played it yet, just read through tutorials and watched videos, so take this with a grain of salt) is that electric signals need a continuous path of redstone dust to travel through, and have a limited propagation distance before needing a redstone torch to boost the signal.  You can't link a single gate to hundreds of triggers all over the map with invisible, instantaneous circuit connections the way you can with mechanisms in DF.  In DF I can link a single pressure plate to hundreds of gears, doors, hatches, and other buildings all over the map, with the links taking up no space in the design, and have all the devices respond instantly when the trigger activates.  I expect this to be the main limitation on making really large, complex computational engines in Minecraft.
Title: Re: Game of Life dwarfputing megaproject
Post by: yaklin on November 02, 2010, 09:15:45 pm
so how much longer till we can do this (http://xkcd.com/505/) in adventure mode?
Title: Re: Game of Life dwarfputing megaproject
Post by: breadbocks on November 03, 2010, 04:29:21 am
Running DF on Minecraft on DF on Minecraft, anybody?
Title: Re: Game of Life dwarfputing megaproject
Post by: MagmaMcFry on November 03, 2010, 11:00:10 am
I realize I'm playing too much DF when I try to combine programs written in FORTRESS, NOBOL, Lava and Drainfuck.
Title: Re: Game of Life dwarfputing megaproject
Post by: Arkenstone on November 05, 2010, 04:57:52 am
Lol, D++? Hm...

Code: [Select]
#include <iostream>
using namespace std;
int main {
      int magma = 0;
      for (char elveshere = 'n'; elveshere != 'y') {
            magma = magma + 1;
            cin>>elveshere; }
      cout<<"DIE F***ING TREEHUGGERS!!!\n"<<magma<<endl; }
cout stands for carnage out ;D
Title: Re: Game of Life dwarfputing megaproject
Post by: lordnincompoop on November 05, 2010, 11:27:44 am
Well, there is D (http://en.wikipedia.org/wiki/D_%28programming_language%29).
Title: Re: Game of Life dwarfputing megaproject
Post by: TolyK on November 05, 2010, 12:56:20 pm
I salute to you, both OP (mostly) and the 3 guys before me.
Title: Re: Game of Life dwarfputing megaproject
Post by: TinyPirate on August 22, 2014, 05:39:47 am
I'm going to bump this because I've been musing on how one would build Conway's Game of Life in Dwarf Fortress - only to discover it has been done! My god! What a thing of beauty! I would love to see this built with minecart logic systems, however!
Title: Re: Game of Life dwarfputing megaproject
Post by: Dorf and Dumb on August 22, 2014, 09:21:55 am
A remarkable feat.

Minor point: sometimes you can cultivate sand by building constructions on Magma Flow at the bottom level, then removing them.  If there is more than one type of base rock down there sometimes you can even try twice, get both sand and clay.  Often you get neither though, so good luck. :)
Title: Re: Game of Life dwarfputing megaproject
Post by: Larix on August 22, 2014, 11:50:58 am
When i found that thread, i was torn between impressed and slightly bummed, since i had also thought about constructing a Game of Life machine. And funnily, while thinking about the options, i had struck upon the very concept Sphalerite used - "counting" the number of active neighbours by calibrating individually-powered circuits to shut down when the load from switched connected gears goes past a crucial threshold. There have been a few simple approximations, too - graphical displays that just go through simple Life patterns without actually running the algorithm. Sphalerite's Game of Life project is one of the great feats of dwarfputing in my book.

Since i didn't see much point in building practically the same thing again, i went and incorporated the gear-resistor concept into my binary multiplier (http://www.bay12forums.com/smf/index.php?topic=132977.msg4748383#msg4748383). I've considered other concepts for the game of life, but the resistor is the most compact core of a life machine i can think of. Using a water counter would be the next best:

For each cell, have an array with eight tiles and eight pumps, a door in each tile. Each door is linked to a neighbouring cell: if that cell is "alive", the door's open, if it's "dead", the door's closed. Now pump water into the array, then shut it off. You'll have one full tile of water for each neighbouring living cell. Now you pump the water out of the cells, into a seven-tile "measuring channel" (requires a split set-up, because at least two pumps must pump into the same target tile); water in the measuring channel is now of the exact depth of the number of living neighbours the cell has. You only need to check for depths two and three, everything else results in a dead cell anyway, so you only need two measuring plates.

Obvious problems - if you end up with one-deep water in the channel, you need some extra work to "flush" it out - pumps won't pick it up, you have to add more water first. If the cell has eight neighbours, you'll end up with seven leftover units of water that'll stay in the lower array, because there'll be no space for them in the measuring channel.

The main problem would be that it'd be horrendously complicated to automate.

PS: no, wait: you'd use a measuring channel of _four_ tiles: if two neighbours are alive, water depth will be 3-4 (one plate measuring four would be enough), if three are alive, it'll be 5-6 (one plate measuring five); everything above would fill the array to capacity, with one living neighbour, it'd spread into 3x2 and 1x1, so only one unit would be left after pumping the water out.
Title: Re: Game of Life dwarfputing megaproject
Post by: PTTG?? on August 22, 2014, 12:42:10 pm
Astonishing.
Title: Re: Game of Life dwarfputing megaproject
Post by: Bartholomew The Pious on August 22, 2014, 05:36:41 pm
Astonishing.
Quite.
Title: Re: Game of Life dwarfputing megaproject
Post by: LuckyLuigi on August 23, 2014, 04:44:46 am
I am so glad you did this  :D