Bay 12 Games Forum

Please login or register.

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

Author Topic: I'm gonna make a calculator!  (Read 4021 times)

qwip

  • Bay Watcher
    • View Profile
Re: I'm gonna make a calculator!
« Reply #45 on: January 14, 2007, 10:34:00 pm »

Maybe somebody has already thought of this in another thread, but here's my proposal for a Dwarf Fortress calculator: DvE Gates (i.e. "Dwarf vs Elephant")  Now, I'm not a CompSci and I'm not a Logician, but with this setup, I think you can recycle your output to become an input in the next calculation.

The basic premise is to open a elephant cage and have an unarmed dwarf walk past the cage to reach the output lever. If the elephant is alive, the dwarf won't make it. If the elephant is killed by drowning or magma -- your preference -- then the dwarf saunters past the elephantine corpse. If you are worried about the possibility of the dwarf getting a lucky shot against the elephant and slaying it, you can increase your confidence level by increasing the number of caged elephants. (Not that I've ever caged an elephant...) The second dwarf's hallway is always flooded to start, as a delaying tactic to let the first dwarf complete his logic tasks.

For all 4 logic gates, the A and B levers are the input. Set the "Pull the Lever" tasks as input, and Dwarf1 ("1") will try to pull them. The A and B levers open/close doors that are either set in parallel, or series. (You could skip the levers and just set the A/B doors as forbidden/open if you want to simplify the set up, or have dwarves from another part of the calculator set the input levers.  The "Go" lever releases both Dwarf1 and Dwarf2 from behind their respective doors. Dwarf1 is free to try to reach the C (or E) lever beyond the doors, but is limited by the logic doors, A and B. Dwarf2 is trying to reach the output lever at the bottom right of the calculator by getting past the delay flood and the possible elephant released from its cage ("!").

======================================
For the OR gate, add "Pull the Lever" tasks to A and B per your input, then every other lever gets a "Pull the Lever" task set: Go,C,Z(already pulled once),C2(already pulled once),E
The Go lever opens the doors in front of both Dwarves, releasing them to try to pull all the other levers. Dwarf1 pulls the A and B levers as appropriate, and if either door is opened, Dwarf1 saunters down to lever C to open the floodgate and drown/boil the elephant(s) in the next hallway.
Meanwhile, Dwarf2 pulls the Z lever and waits for the floodgate to close and the floodwaters to recede, which is just a delaying tactic. (Note the judiciously placed channels to keep from drowning/boiling Dwarf2 from either floodgate.) Next Dwarf2 pulls the C2 lever, which closes the first floodgate that Dwarf1 may or may not have opened. Then Dwarf2 pulls the E lever which opens the cage ("!") to a live or dead elephant. If Dwarf2 makes it past the elephant, Dwarf2 pulls the output lever.

OR  (kill the E, let D live)

code:

          #~####
          #~##2#
          #~##D(Go)
          #~#Zó#
          #~##_#
          #~~X~#
          #~#Z~#
          #~##~#
          #~##~#
          #~##óC2
          #~##òE
          #~##~#
          #~##_#
      #A###~X..#
   #Go#òD.##C#!E
   #1òD.#...ò#.#
   ####òD.####ò  output lever
      #B###


       
A+, B+ ==> A and B doors both open, D1 floods cage from C lever, D2 unfloods cage, opens cage, walks past corpse. Output true.
A+, B- ==> A door opens, D1 floods cage from C lever, D2 unfloods cage, opens cage, walks past corpse. Output true.
A-, B+ ==> B door opens, D1 floods cage from C lever, D2 unfloods cage, opens cage, walks past corpse. Output true.
A-, B- ==> A and B doors closed, elephant cage never flooded, D2 opens cage, D2 is stomped tragically. Output stays false.

(Now that I've described it in a simplified(!) manner, there's two pieces tht need to be added. The cage release lever also needs to open a door that allows access to the output lever. Otherwise there's the possibility that D2 will be taskes to Pull the output lever first, before opening the cage. And I think I may need a second unflooding delay. After Dwarf1 completes his logic, he needs to wait for Dwarf2 to pull the output lever or not, and then once enough time has passed, Dwarf1 would pull the "go" lever on the next calculation.)
======================================
Here's the AND gate, same set up, just with the A/B doors in series, not parallel.

AND (kill the E, let D live)

code:

           #~####
           #~##2#
           #~##D(Go)
           #~#Zó#
           #~##_#
           #~~X~#
           #~#Z~#
           #~##~#
           #~##~#
           #~##óC2
           #~##òE
           #~##~#
           #~##_#
      ######~X..#
   #Go##A#A##C#!E
   #1òD.òòDD.ò#.#
   ######B#B###ò  output lever

A+, B+ ==> A and B doors both open, D1 floods cage from C lever, D2 unfloods cage, opens cage, walks past corpse. Output true.
A+, B- ==> only A door opens, elephant cage never flooded, D2 opens cage, D2 is stomped tragically. Output stays false.
A-, B+ ==> only B door opens, elephant cage never flooded, D2 opens cage, D2 is stomped tragically. Output stays false.
A-, B- ==> neither A/B door opens, elephant cage never flooded, D2 opens cage, D2 is stomped tragically. Output stays false.
======================================
For the NOR and NAND gates, we can skip the elephant flooding and have Dwarf1 try to pull the cage lever ("E") directly. Both dwarves are again released by the "go" lever and Dwarf2 is must wait for the delaying flood to recede after pulling lever Z. Dwarf1 goes through doors A or B, if at all, and tries to release the elephant cage ("!"). Dwarf2 must pull lever C to open Door C to get to the output lever.

NOR  (release the E, kill the D)

code:

            #~####
            #~##2#
            #~##D(Go)
            #~#Zó#
            #~##_#
            #~~X~#
            ###Z~#
               #~#
               #~#
               #~#
               #òC
               #~#
               #_#
    #####A###  #.#
    #Go#òD.##E#!E
    #1òD.#...ò#.#
     ###òD.####DC
      ##B###  #ò# output lever

A+, B+ ==> A and B doors both open, D1 opens cage, D2 is stomped tragically. Output stays false.
A+, B- ==> A door opens, D1 opens cage, D2 is stomped tragically. Output stays false.
A-, B+ ==> B door opens, D1 opens cage, D2 is stomped tragically. Output stays false.
A-, B- ==> neither A/B door opens, elephant cage never opened, D2 walks past cage. Output is true.
======================================
NAND  (release the E, kill the D)

code:

            #~####
            #~##2#
            #~##D(Go)
            #~#Zó#
            #~##_#
            #~~X~#
            ###Z~#
               #~#
               #~#
               #~#
               #òC
               #~#
               #_#
    #########  #.#
    #Go##A#A##E#!E
    #1òD.òòDD.ò#.#
    #####B#B####DC
       ######  #ò# output lever

A+, B+ ==> A and B doors both open, D1 opens cage, D2 is stomped tragically. Output stays false.
A+, B- ==> only A door opens, elephant cage never opened, D2 walks past cage. Output is true.
A-, B+ ==> only B door opens, elephant cage never opened, D2 walks past cage. Output is true.
A-, B- ==> neither A/B door opens, elephant cage never opened, D2 walks past cage. Output is true.
======================================
And I guess I ought to mention the NOT gate, because it might be easier to implement a NOT(NOR(A,B)) than an OR(A,B). (I'm sure I messed up the logic syntax, but you get the idea...)
A NOT gate is a corridor with the caged elephant, and no A/B door logic. If cage is opened (input=TRUE), then Dwarf2 dies (output=FALSE).

Ok, now that I've typed all this in. Where did I screw up?

(EDIT: I got the [code] tags in wrong place)

[ January 14, 2007: Message edited by: qwip ]

Logged
qwip

Efficiency is intelligent laziness

Ksero

  • Escaped Lunatic
    • View Profile
Re: I'm gonna make a calculator!
« Reply #46 on: January 16, 2007, 05:21:00 am »

The dwarf-powered NAND gate. Not as impressive as the elephAND one. And it's not as elegant as a water-powered one would be. But still...
Each "bit" has four states, so two levers are required to define the initial state of a bit.
code:

L1 | L2 | State
0  | 0  | calculation inactive.
0  | 1  | active low
1  | 0  | active high
1  | 1  | not permitted

NAND:
########
#..a.B.#
#..#.b.
#1.#####
#..b.A.
#..#.a.#
########
#2.A.B
########



1,2 - the L1 and L2 levers
A - door connected to the first input's L1 (ie. passable when input is high)
a - door connected to the first input's L2 (passable when input is low)
B - door connected to the second input's L1
b - door connected to the second input's L2

Instruction for the dwarvish operator:
after setting up the initial state of the machine, run around and try to pull all the levers you can [ie. have one pull job for every lever]. When you can find no more levers to pull, the calculation has been performed.


NOT
###
#1a
###
#2A
###

[ January 16, 2007: Message edited by: Ksero ]

Logged

Ksero

  • Escaped Lunatic
    • View Profile
Re: I'm gonna make a calculator!
« Reply #47 on: January 16, 2007, 07:08:00 am »

Thinking about this further, one problem is that the previous model is one-shot. Once a gate has found its value, it never changes. So let's look at the not gate again (see above for the original one-shot version).

code:

####..
WX_#..
##_###
#1_..a
###Ee#
#2_..A
##_###
WX_#..
####..


E - passable when L1 is in the yanked position
e - passable when L2 is in the yanked position
W - water
X - floodgate

the channels are there to prevent the forbidden state (1, 1). The upper floodgate is connected to the bottom lever and vice versa. So when lever two is in the pulled position, you can't access lever one. Let's walk through a couple of state changes.

code:

InputL1   | InputL2   |  OutputL1   |  OutputL2   |  open doors   |   State
0   |   0   |   0   |   0   |      |   Rest
0   |   1   |   0   |   0   |   a   |   Input changes to false
0   |   1   |   1   |   0   |   a E   |   Dwarf 1 yanks lever 1
0   |   0   |   1   |   0   |   E   |   Input is turned off
1   |   0   |   1   |   0   |   A E   |   Input changes to true
1   |   0   |   0   |   0   |   A   |   Dwarf 1 walks through the middle passage and yanks lever 1
1   |   0   |   0   |   1   |   A e   |   Dwarf 2 yanks lever 2, freeing Dwarf 1


Someone would have to add a new pull lever job to lever 1 to have it reset. Maybe a new noble could be appointed, the YankMeister, who would let you schedule Pull Lever jobs at the manager's job list?     :)

[ January 16, 2007: Message edited by: Ksero ]

Logged

Ksero

  • Escaped Lunatic
    • View Profile
Re: I'm gonna make a calculator!
« Reply #48 on: January 16, 2007, 05:55:00 pm »

This is interesting         :D. Here's yet another proposal. The logic uses the same system as the dwarf-powered one.
code:

L1 | L2 | State
0  | 0  | calculation inactive.
0  | 1  | active low
1  | 0  | active high
1  | 1  | not permitted


The basic idea: The ever-running elephant. Place a wild elephant between the levers 3 and 4.

code:

###D#C###                ####D###
#.._._..#                #..C_..#
#.#####,##################.####.#
#..C.D.....3.........4.....D_..#
#.###########################C#.#
#.                             .#
#   To Freedom                 .#
   v            v

3 - corridor pressure plate - connected to doors/floodgates C
4 - corridor pressure plate - connected to doors/floodgates D

note:
##D##
#._..
#####
is a floodgate connected to pressure plate 4, flooding the channel below when the plate is in the "pressed" position


Imagine that floodgates worked instantly. In this map, there are two exits, left and right. The left one is open in states 00 and 11, and the right exit is open in the other states. The right one is open in states 10 and 01:

code:

          .  pressure plate 3
          |
          |  0     |    1
        --+--------+--------
pressure 0 |        |
plate 4    | left  --> right
          |   ^    |    |
        --+---|----+----|---
        1 |   |    |    v
          | right <-- left


If we start in state 00, with the elephant in the middle. "left" means that the left exit is the only one open. So the elephant runs towards it, and steps over switch 3. Which closes the left exit and opens the right exit. So the elephant instantly turns and runs rightwards. Until he trips over pressure plate 4... and so the elephant runs back and forth between the levers chasing his precious freedom that the cunning dwarves have forever denied him.

To power a logic gate with the elephant, place a section between the levers that forces the elephant run through the logic.

NOT GATE

code:

###D#C###                                ####D###
#.._._..#                                #..C_..#
#.#####,##################################.####.#
#..C.D.....3........D.................4.....D_..#
#.#############.###.C.###########.###########C#.#
#.            #.########        #.#            .#
# To Freedom  #.#               #_DW            .#
             #.#               #.#
             #.#  no change    #_CW
             #.#########needed #.#
             #.........#       #.#
             Wg______#.#       #.#
             #.##F##E#E#########.#
             #..5_.._..........B.# These doors implement
             #.###EF############.# the NOT function,
             #..6_.._..........A.# calculating what we
             #.##E##F#F########### should output
             Wg______#.#
             #.........#
             ###########
                No change needed

1 - logic input "high" - connected to door A
2 - logic input "high" - connected to door B
3 - corridor pressure plate - connected to doors/floodgates C
4 - corridor pressure plate - connected to doors/floodgates D
5 - logic output pressure plate "high" - connected to doors/floodgates E
6 - logic output pressure plate "low" - connected to doors/floodgates F



Other gates can easily be constructed from this pattern. The only NOT-specific part is the A and B doors.

the upper logic forces the elephant to enter the bottom part when it's walking leftwards in state 00. If the input is inactive, the elephant will have to wait until it's active. To maintain elephant health and speed, a bypass could be introduced in the upper chamber.

code:

##################
W_________########
#######A#B########
###### _ _ #######
###### ### #######
       C
### ### D ## #####
 # ######## #

Note: The implementor will have to compensate for the activation time of the flood gates. Also, note that without instant activation, the elephant will probably run past the pressure plates 3 and 4, requiring additional doors and channels to avoid that it eg. resets pressure plate 3 when he runs for pressure plate 4.

[ January 16, 2007: Message edited by: Ksero ]

Logged

needsmoresalt

  • Escaped Lunatic
    • View Profile
Re: I'm gonna make a calculator!
« Reply #49 on: January 18, 2007, 11:59:00 am »

quote:
Originally posted by segmose:
<STRONG>The levers need to have an opposit setting for some of their gates which cant be made at the moment.</STRONG>

I've been reading this thread and I have an idea.

Floodgates aren't the only thing that blocks water and can be connected to a lever, you can also connect drawbriges. Since the default state of drawbridges is down (ie. open) and the default state of floodgates is closed, if you connect them both to the same switch they'll be in opposite states.

I havn't tested it so there may be issues, but it sounds easier (and safer      :)) than using elephants

Edit:
it also occurs to me that this dosn't solve the problem w mentioned above (that the output for one operation can't be used as the input for another) since I can't think of a way to make any gates other than OR that use water as both input and output.
Ofcourse it's possible I'm missing something.

What we really need is a way to make something switch depending on the presence or absence of water at a specific location, then we're pretty much set.

[ January 18, 2007: Message edited by: needsmoresalt ]

Logged

4bh0r53n

  • Bay Watcher
    • View Profile
    • http://www.phpbber.com/phpbb/index.php?c=1&mforum=abhorsengames
Re: I'm gonna make a calculator!
« Reply #50 on: February 14, 2007, 05:04:00 am »

quote:
add the line:

code:
--------------------------------------------------------------------------------

[SPEED:1]

--------------------------------------------------------------------------------



this makes it very funny....
got two movies to post showing miners at speed:1
anyone know how to put them up here?

Logged
.B.H.O.R.S.E.N.: Abhorrent, Bloodthirsty, Hitchhiker-Obliterating Ravager from the Sunless Enchanted Necropolis

I dont explode Cats, its way to hard to coax them into the microwave...

Pages: 1 2 3 [4]