Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Dwarven Animal/Borg Logic  (Read 3693 times)

Rotten

  • Bay Watcher
    • View Profile
Dwarven Animal/Borg Logic
« on: May 07, 2010, 11:02:55 pm »

As much as I would like, this does not involve elves being assimilated and becoming bio-engineered dwarves inside a giant floating obsidian cube.

Instead, after reading an old 40d wiki page on computing, I noticed the section on animal logic (also, Borg logic, whatever difference from animal logic it has :\). Having never considered it as a viable possibility beyond simple repeaters, not being able to find any examples of a practical gate made with it, and knowing that water logic was much more efficient and killed FPS less, I decided to try it and whipped up some designs for logic gates instead of the numerous more important deadlines looming. Hey.

I eventually decided on a mixture of my previous research area, gear logic (which I abandoned after proving that a NOT gate is impossible without triggering, thus also making a NAND, XOR and NOR gate impossible, making any sort of useful logic construction impossible). After searching, I decided that the first prototype will be a simplified Von Neumann architecture (removed CU, opcode comes later when stuff works, AU simplified to an 8 bit adder and rewired some connections to make it run better in DF). So while the first prototype will be a glorified calculator (simple addition and an 'add answer' function), the next prototype will be more complicated. My goal right now is just to prove that my logic gates WORK.

Massive text wall ahead. If you don't want any nitty-gritty details, avert eyes now:
------------------------------------------------------------------------------------------
Components
A simplified Von Neumann architecture consisting of an adder, gear memory, lever input, input control and door matrix output

Memory
I adapted this from previous gear logic projects. I call it Power Tested Gear Memory, as that is exactly how it works. Each bit of memory consists of a gear assembly linked up to the corresponding output bit, a power source, and a pump+pressure plate power sensor. The memory stores state as a toggled or disengaged gear. When the +ANS function is used, power is 'flooded' through the gears, testing each for it's state. If it is toggled, it will activate the pump, which will trigger a pressure plate.
Code: [Select]
Single memory cell (one bit)
# is a wall
| is a horizontal axle carrying >=20 power
X> is a pump pumping east
~ is 7/7 water 1 z level down (pump source)
$ is the drain (probably all drains lead to central reservoir that drains into caverns)
O is the linked gear assembly (* was to hard to see)
D is access door
^ is output pressure plate

###|###
###O###
##~X>^$
##D####
This will suck up a fair bit of power (~20 power X 9 bits= 180 power, about 2 waterwheel's worth), but will only have a 200 step delay, which is important.
The memory is 9 bits to accommodate the addition of two 8-bit numbers (as, for example, 11111111+11111111=111111110, which is obviously 9 bits)

Adder
This would also be 8 bit, to couple with the memory. Since I'm lazy still in test phase, I'm going to use the simpler ripple-carry adder over a carry-look ahead design. Since I have built half-adders (a) before, that will be first, and then follow up with the 7 full adders (A).
Code: [Select]
Ripple-carry adder
> is a carry
o is a bend in the linkups
in-------------
| | | | | | | |
a>A>A>A>A>A>A>A-o
| | | | | | | | |
out------------------>
Each adder adds 2 bits (one from each number) and the carry value (except half adder). The carry 'ripples' through from the first to the last adder. Despite deriding, it is actually pretty fast, the carry operations by themselves should end up taking roughly 800 steps. That's not terrible, and actually improves FPS (as not every animal is pathing around at quite the same time)...

Gates
Universal key:
# is wall
A through G is door
d is normally open door
g through k is pressure plate
M is a meeting area (used to lure animals around)
+ is normal floor
a and b are lever or pressure plate inputs, not actually shown.
O is the on door (this door is triggered after inputs have been inputted, releases animal after inputs are done to prevent mishaps)
Code: [Select]
AND

############
#+O++g++ABM#
############

Input a is hooked up to door A, and b is hooked up to B. The animal's 'default' position is behind g. I designed an off mechanism to lure them back there to reset the computer, but I'll go into that later. When both a and b are triggered, the animal begins to move towards M. It triggers pressure plate g, sending a on signal as the output and closing doors A and B to prevent it from getting stuck in M (which would require annoying meeting area fiddling to resolve). The previously mentioned off mechanism would then lure it back behind g.

Code: [Select]
OR

#####
#+M+#
#A#B#
#+#+#
#+#+#
#g#h#
#+++#
##O##
##+##
#####

Obviously this is quite a bit larger than the AND, mainly as it needs two paths for OR to properly work. Otherwise identical to AND. If a is triggered, A opens and g is triggered, closing A and sending ON, same with b (though opening B and triggering h). If both a and b are triggered, then both A and B are opened. g and h will both also be triggered. I'll need to make sure that doesn't mess the computer up.

Code: [Select]
XOR

###
#M#
#A#
#+#
#+#
#g#
#+#
#O#
#+#
###
This one is easy to understand. Both a and b trigger A. a only sends output on, b only same, both means a opens the door and b closes it (or vice-versa) meaning an output of off.

Code: [Select]
NAND


#####
#+M+#
#A#B#
#+#+#
#+#+#
#g#h#
#+++#
##O##
##+##
#####
The sharp observer will note that this is the OR gate. It functions in the same way, except that A and B start out open.

Code: [Select]
NOT

###
#M#
#A#
#+#
#+#
#g#
#+#
#O#
#+#
###
A NOT gate has only one input, a. a is linked to A, which starts out open.

Inputs
Levers.

Input controller
Hard line, huh? Hmph. Input controller basically splices together the number in memory if ANS is selected. It triggers memory to read out, then uses that and the lever pull as inputs. It's hard to diagram since it's spread out among the other parts. Mainly the pressure plates in memory.

Bin to Dec converter
I really want one of these. It will convert the 9 bit output to a 3 digit decimal. I'm still working out a design for it though.

Door Matrix Output
Basically a big square of doors that are triggered by the bin-to-dec converter like a standard LCD screen.
D is door
# is untriggered door or wall
Code: [Select]
###D##DDD##DDD#
###D##D####D#D#
###D##DDD##D#D#
###D####D##D#D#
###D##DDD##DDD#
150
Code: [Select]
#DDD##DDD##D#D#
###D####D##D#D#
#DDD##DDD###D##
###D####D##D#D#
#DD##DDD###D#D#
33X. Absolutely not a hint at what is eventually planned for this computer.

Planned Testing and Dev
Test gates, memory, sensors and other components for basic functionality
Test half and full adders
Test basic computer design (what is outlined in this post)
Test basic carry-look-ahead adder
Decide on final architecture of computer
Design other components for architecture
Construct
Program
???
Profit!

« Last Edit: May 07, 2010, 11:30:53 pm by Rotten »
Logged
True, but at a certain velocity the resulting explosion expels invader-bits at fatal speeds. You don't want to be dropping trogdolyte-shaped shrapnel bombs into your boneworks.
Only in Dwarf Fortress...

Fossaman

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #1 on: May 08, 2010, 02:15:48 am »

I want to know how many mechanisms this uses when you're done.

You sir, are a mad genius. Never let those fools at the university tell you otherwise.
Logged
Quote from: ThreeToe
This story had a slide down a chute. Everybody likes chutes.

s22190

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #2 on: May 08, 2010, 04:25:53 am »

This is definately dwarven.
Logged

Dave Mongoose

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #3 on: May 08, 2010, 06:06:07 am »

I'm not 100% sure, but I think this design would only work with dwarven pathfinding:

Animals will pathfind even if a door is in the way (they'll just stop at the door and flash ?s), so you'd need to put the pressure plates behind a flipped door, not in front.

Also, how do you plan to make these gates reset? They seem to all go one way.

Hatch covers would be easier to use than doors for the display screen, because they don't require adjacent walls (you can use doors, but you need to be careful what order you build them in and 'cheat' a bit with constructing and removing walls.

On the technical side, I would recommend two's complement binary as it lets you have negative numbers and subtraction 'for free'.

Most importantly: good luck :) I've always wondered why animal logic isn't more popular, since it can be more reliable than fluid logic.
Logged

Rotten

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #4 on: May 08, 2010, 06:58:48 am »

Thanks.
I want to know how many mechanisms this uses when you're done.

You sir, are a mad genius. Never let those fools at the university tell you otherwise.
Well, my legendary mechanic can hopefully keep up. Thanks!
This is definately dwarven.
Maybe not as much as the elf assimilation cube (someone should build that...).
I'm not 100% sure, but I think this design would only work with dwarven pathfinding:

Animals will pathfind even if a door is in the way (they'll just stop at the door and flash ?s), so you'd need to put the pressure plates behind a flipped door, not in front.

Also, how do you plan to make these gates reset? They seem to all go one way.

Hatch covers would be easier to use than doors for the display screen, because they don't require adjacent walls (you can use doors, but you need to be careful what order you build them in and 'cheat' a bit with constructing and removing walls.

On the technical side, I would recommend two's complement binary as it lets you have negative numbers and subtraction 'for free'.

Most importantly: good luck :) I've always wondered why animal logic isn't more popular, since it can be more reliable than fluid logic.
Thanks! I do have a design for a reset switch, but I forgot to add it. That's what I get for posting at 1 AM.
Basically, when the OFF lever is pulled it starts a timer that opens, then closes a door with a meeting area behind it. For instance, the complete AND gate:
Code: [Select]
###
#M#
#B#
#A#
#+#
#+#
#g#
#+#
#O#
#+#
#Z#
#M#
###
The Z is the 'off door'
The timer is simple (though water based, sorry!)
Code: [Select]
#########
$h<Xg<X~#
#########
Both pumps are hookedup to 10 power. When the off lever is pulled, the rightmost pump starts, pumping water from ~ onto the pressure plate g, which after 100 steps delay triggers all the O 'off doors' in every gate to open and the second pump,which pumps water onto h, which after another 100 steps closes all the Z doors. So they will all be open for 100 steps, and do to the pathfinding you mentioned this will cause the animal to run over to that door, perfect for another run of the gate.
This door is different than the O 'on' door mentioned, as those need to be there too. Basically the animal will always be between O and Z when the gate is inactive, and return to this spot after it has finished calculating. This is to prevent messups, mainly with the XOR gate (as with 2 inputs, it would open quickly then close, which might cause the animal to pathfind towards it, giving a false ON signal).
Also I was under the impression that two's complement required you drop the most significant bit (so that the adder woudl be a 7 bit adder/subtractor). I guess building another adder isn't that bad though.
« Last Edit: May 08, 2010, 07:10:01 am by Rotten »
Logged
True, but at a certain velocity the resulting explosion expels invader-bits at fatal speeds. You don't want to be dropping trogdolyte-shaped shrapnel bombs into your boneworks.
Only in Dwarf Fortress...

melomel

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #5 on: May 08, 2010, 09:12:25 am »

I am heartily disappointed by the lack of actually game modding for nano-probes.  >:[

The concept, however, I must endorse heartily.  And by endorse, I mean inject with nano-probes and insert into cyber-vats..  (How much d'you think we'd have to bribe Sir Toady to do a SF version of DF?  "Feeding cancelled:  organic nutrient sludge in tube 11b insufficient for biomass. x15  Feeding cancelled:  supply drone requisitioned for refilling nutrient vats.  x8.")
Logged
I HAVE THREE HUNDRED THOUSAND CRAFT ITEMS. I WILL TRADE THEM ALL FOR CHEESE.
7+7

ThtblovesDF

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #6 on: May 08, 2010, 12:43:58 pm »

Turning elfs into dwarfs just takes a few serated discs and giving them a axe to kill some trees...
Logged

darkrider2

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #7 on: May 08, 2010, 05:06:26 pm »

Quote from: ThtblovesDF
Turning elfs into dwarfs just takes a few serated discs and giving them a axe to kill some trees...

I'm sigging this...
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #8 on: May 09, 2010, 02:31:33 pm »

I eventually decided on a mixture of my previous research area, gear logic (which I abandoned after proving that a NOT gate is impossible without triggering, thus also making a NAND, XOR and NOR gate impossible, making any sort of useful logic construction impossible).

How does your proof work? What do you mean by triggering?
Logged

Rotten

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #9 on: May 09, 2010, 02:50:47 pm »

I eventually decided on a mixture of my previous research area, gear logic (which I abandoned after proving that a NOT gate is impossible without triggering, thus also making a NAND, XOR and NOR gate impossible, making any sort of useful logic construction impossible).

How does your proof work? What do you mean by triggering?
Basically, gear logic was using gear resistors and power amounts to construct logic gates. If you think about it, you can then make an AND gate if A provides 10 power, B provides 10 power and the gate itself has 19 resistance. C, if A and B are both triggered (turned on by lever) will then get 1 power. If you increase A or B in the right way, then C will also get 10 power, so it can act as the input for another gate.

The problem with this system, is though you can make a NOT gate output 0 when it's input is 1 (extremely high resistance), you cannot make a NOT gate output 1 when it's input is 0. While you can do it with pumps and pressure plates, it defeats the purpose of using gear logic over less complicated water logic or animal logic in the first place (as gear logic is complicated due to the multiple pathways power wants to take through the system via backflows through untriggered gates, which can then flow to gates that shouldn't trigger, which messes stuff up).

Triggering is changing the gear's state with a lever/pressure plate.
« Last Edit: May 09, 2010, 02:52:20 pm by Rotten »
Logged
True, but at a certain velocity the resulting explosion expels invader-bits at fatal speeds. You don't want to be dropping trogdolyte-shaped shrapnel bombs into your boneworks.
Only in Dwarf Fortress...

bdog

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #10 on: May 09, 2010, 03:13:38 pm »

Shameless advertisement http://df.magmawiki.com/index.php/User:Bidok (its quite old and tested in 40d, also there's nicer AND gate on talk page)

My animal logic was based more on pathing bug and the fact that closing doors/floodgates would move said animal to next free tile.
I'm not sure if it's still working but feel free to check it/test it/use it ^^,
Logged

Rotten

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #11 on: May 09, 2010, 03:20:09 pm »

Shameless advertisement http://df.magmawiki.com/index.php/User:Bidok (its quite old and tested in 40d, also there's nicer AND gate on talk page)

My animal logic was based more on pathing bug and the fact that closing doors/floodgates would move said animal to next free tile.
I'm not sure if it's still working but feel free to check it/test it/use it ^^,
Thanks, was interesting. Trying to use only 1 animal per gate though, for pathing reasons. Also, what do you mean by "would move said animal to the next free tile" It would teleport it? I thought they just got stuck open in 40d. That could pretty easily be replaced with a timer/meeting area lure though.
Logged
True, but at a certain velocity the resulting explosion expels invader-bits at fatal speeds. You don't want to be dropping trogdolyte-shaped shrapnel bombs into your boneworks.
Only in Dwarf Fortress...

bdog

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #12 on: May 09, 2010, 03:35:53 pm »

Yes, they were teleporting to next free tile.
I'm not sure if its still working in 0.31 but it wouldn't be hard to check it with NOT gate. (doors, floodgates and grates; because they did work kind of different)
Logged

Fluff

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #13 on: May 09, 2010, 04:09:04 pm »

Turning elfs into dwarfs just takes a few serated discs and giving them a axe to kill some trees...

And the beards?
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: Dwarven Animal/Borg Logic
« Reply #14 on: May 09, 2010, 07:40:50 pm »

Basically, gear logic was using gear resistors and power amounts to construct logic gates. If you think about it, you can then make an AND gate if A provides 10 power, B provides 10 power and the gate itself has 19 resistance. C, if A and B are both triggered (turned on by lever) will then get 1 power. If you increase A or B in the right way, then C will also get 10 power, so it can act as the input for another gate.

The problem with this system, is though you can make a NOT gate output 0 when it's input is 1 (extremely high resistance), you cannot make a NOT gate output 1 when it's input is 0. While you can do it with pumps and pressure plates, it defeats the purpose of using gear logic over less complicated water logic or animal logic in the first place (as gear logic is complicated due to the multiple pathways power wants to take through the system via backflows through untriggered gates, which can then flow to gates that shouldn't trigger, which messes stuff up).

Triggering is changing the gear's state with a lever/pressure plate.

Ah, ok. But hybrid gear/water systems might be more efficient than purely water-based logic, in terms of how many frames it takes to compute. You could design a system with a few inputs controlled by pressure gates or switches, and then output the result based on water while doing all the computation in between using gears. But this is getting a bit off-topic.
Logged