Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: The ridiculously overblown abacus  (Read 3052 times)

Larix

  • Bay Watcher
    • View Profile
The ridiculously overblown abacus
« on: July 23, 2013, 03:45:44 pm »

Fuck, took too long to compose the message and the forum swallowed everything i typed upon asking for a preview. So this is gonna be a bit terse:

I built an adding machine. All based on perpetual-motion minecarts and hatch-operated pathing logic.
Spoiler (click to show/hide)
Result: too much: after reset:
It's better at binary than i am :P I actually mis-calculated both results and only got the correct result (which the machine of course got) after going through the number twice.
« Last Edit: July 28, 2013, 07:26:43 pm by Larix »
Logged

Larix

  • Bay Watcher
    • View Profile
Re: The ridiculously overblown abacus
« Reply #1 on: July 23, 2013, 03:46:26 pm »

Inner workings of The Marble Bookkeeper:

Counting numbers:
Spoiler (click to show/hide)

Automated input:

Spoiler (click to show/hide)

Writeable "memory":
Spoiler (click to show/hide)
« Last Edit: July 28, 2013, 07:29:09 pm by Larix »
Logged

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: The ridiculously overblown abacus
« Reply #2 on: July 23, 2013, 05:31:26 pm »

This one's just a simple integrator, but impressive all the same.

I'd be much more impressed with an instruction pipeline, and a microcode array based general purpose cpu design though.

Say, an implementation of MOS6502.

It would probably bring df to its knees though.
Logged

Larix

  • Bay Watcher
    • View Profile
Re: The ridiculously overblown abacus
« Reply #3 on: July 23, 2013, 07:32:01 pm »

Inte-what? What kind of pipeline? Microcode?
I don't understand a word. I was just banging stuff together and having fun. If this gives anyone ideas to follow up on, so much the better.

Just a word of warning - thirty to forty carts buzzing around simultaneously already make DF pretty unhappy, even more so when several additions take place at the same time. Sometimes i was worried the read-write cart was going too slowly and might just stop, but it was only the game slowing down...
Logged

Tevish Szat

  • Bay Watcher
  • [PREFSTRING:diabolical schemes]
    • View Profile
Re: The ridiculously overblown abacus
« Reply #4 on: July 23, 2013, 07:50:30 pm »

Dwarven computing (that is, building a functional computer inside DF) is, surprisingly, decently developed.

Some day, we'll develop a dwarfputer capable of taking complex enough input to run Adventure, though I shudder at the size of embark that would be needed for the RAM and processor.
Logged
A medium-sized humanoid fond of fantasy and science-fiction.

Tevish Szat likes books, computers, board games, and cats for their aloofness. When possible, he prefers to consume hamburgers and macaroni and cheese. He needs caffeine to get through the working day.

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: The ridiculously overblown abacus
« Reply #5 on: July 23, 2013, 08:17:57 pm »

*bah.

Double your pleasure, double your fun; android phone makes doubleposts, son!
« Last Edit: July 23, 2013, 08:52:34 pm by wierd »
Logged

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: The ridiculously overblown abacus
« Reply #6 on: July 23, 2013, 08:18:24 pm »

Inte-what? What kind of pipeline? Microcode?
I don't understand a word. I was just banging stuff together and having fun. If this gives anyone ideas to follow up on, so much the better.

Just a word of warning - thirty to forty carts buzzing around simultaneously already make DF pretty unhappy, even more so when several additions take place at the same time. Sometimes i was worried the read-write cart was going too slowly and might just stop, but it was only the game slowing down...

in computer lingo, an "integrator" is a simplistic computer capable of doing "integration", eg, very basic mathematics, like addition and subtraction, in an ordered and programmable manner.

"Mircocode" is a programmable set of what are essentially switches, that controls what gates inside a processor engage when presented with an instruction word on the instruction pipeline. Errors in the way a CPU processes data can be corrected by updating the CPU's microcode, which is why it is used. It is basically a very tiny EEPROM adjacent to the main ALUs inside the CPU's processing center. Some CPUs, like the NEC V20, did not use microcode, and instead used hard wired logic. That cpu was measurably faster than the intel chip it was competing with, because the processor didn't have to evaluate the microcode in order to perform an operation. But, because it was hard wired, the chip could not be corrected if an error in that logic was discovered. Thankfully for NEC, they never found one.

And, an "instruction pipeline" is an ordered list of computer "words" (2 byte being the smallest usually used) that tell the processor what to do with data presented to it on its input registers, which gets pushed and pulled as needed as the computer executes the instructions in the list.

One of the most well known and replicated general purpose processing chips that has all of those features is the MOS6502 cpu, created by MOS semiconductor in the mid 70s.  It was the heart and soul inside a great many devices for quite some time, including but not limited to, the Nintendo NES, the C64 home computer, the first apple macintosh, and many others. (Modern implementations of the cpu are still frequently fabbed for embedded devices! It's just that awesome!)

The wiring diagram and logic table for the MOS6502 is widely available, and is a favorite for cpu hobbyists to replicate using discrete logic components, to better understand the way that general purpose CPUs operate.

It is one of the few general purpose cpus that are simple enough inside for a single person to fully grasp what it is doing at all stages of execution.

Implementing a MOS6502, and a simple 2D bitmap array (say, a field of raising drawbridges) with an instruction pipeline and a memory array would allow the resulting computer to run quite a number of existing software programs from yesteryear pretty much out of the box.

You might even be able to find an implementation of ROGUE. ;D. It is about the right era.

« Last Edit: July 23, 2013, 08:38:25 pm by wierd »
Logged

InfinityOrNone

  • Bay Watcher
    • View Profile
Re: The ridiculously overblown abacus
« Reply #7 on: July 24, 2013, 01:39:28 am »

It's threads like these that make me want to steal a Cray and do unspeakable things to it until it will play DF, then use it to create a Dorfputer able to play a smaller game of DF on itself.
Logged

Snateraar

  • Bay Watcher
  • [INORGANIC:BIRD_CRAZY]
    • View Profile
Re: The ridiculously overblown abacus
« Reply #8 on: July 24, 2013, 03:42:50 am »

Now, make a random number generator.
Logged
Urist McSnate likes malachite, copper bars, birds and goblinite for its abundance. When possible, he prefers to consume tea and toast. He absolutely detests elves.

A tall, clumsy creature fond of birds and industry.

Larix

  • Bay Watcher
    • View Profile
Re: The ridiculously overblown abacus
« Reply #9 on: July 24, 2013, 04:29:24 am »

EDIT: simple randomish bit generator, one of my first designs:

Takes any input, opens both hatches and the cart more-or-less-randomly ends up either in the left or the right loop. On an 'off' signal, the cart returns to the middle stretch, bouncing between the hatches and awaiting new input. With a counter and 'programmable' memory, this could be used to set individual memory cells either on or off. Four steps should generate a four-bit random number.

Circuits used in the Trinity Clock

The Oscillator:
Spoiler (click to show/hide)

Adding up:



Spoiler (click to show/hide)

Counting the hours:

Spoiler (click to show/hide)

Display:
A single-'dial' clock face for the hours, 'sliders' for the longer units:



Spoiler (click to show/hide)

Timely processes

Spoiler (click to show/hide)

Individual circuits/logic gates i used:

four-input AND gate, to check for a specific day (checking 3rd season, 1st month, 2nd week, 6th day to only return true when it's the 13th of limestone).


three-input AND, to check for a specific week (1st season, 1st month, 1st week). All ramps straight EW, the cart's on a NW track corner, the first input is on (might be spring).


Two separate AND gates, built next to each other to save space (parallel ramp-pits can be placed right next to each other, they won't interfere).
Spoiler (click to show/hide)

An improved and tested three-input OR/NOR gate:

Cart is on a SW track corner right now, the NOR pressure plate would be on the tile directly to the west, the OR plate on the NW track corner directly southwest of it. I tried both options for the return track of the second check (going straight east) and the southern return loop works better. The circuit has return times between 46 and ~65 steps.

A tested and proven four-input OR (with limited NOR functionality):

This thing _does_ work, but the return time for the NOR signal is impractically long - i counted 99 steps. The return times for OR signals are a bit more useful, being 46, 62, 62 and 87 steps, depending on which is the 'earliest open' hatch. The NOR plate is the northeastern, the OR plate the southwestern one.
« Last Edit: July 28, 2013, 07:33:14 pm by Larix »
Logged

Larix

  • Bay Watcher
    • View Profile
Re: The ridiculously overblown abacus
« Reply #10 on: July 28, 2013, 03:01:25 pm »

EDIT: I got the fake negative display fixed. Only took a few hours :P Scroll down, way down.

Update:
The Marble Bookkeeper has proved its abilities at adding up, accepting 12-digit binary numbers and being capable of adding up to 14 bits (-1, so 16383 decimal), rating it at 'high' precision. Since then, i've once again browsed The amazing account of the Almighty Dwarven Calculator. While i lack the expertise and ambition to rival that achievement, i decided to add (rudimentary) subtraction and multiplication capability to what i've built, just to see if i could get my head around the principles.

I think i've had some success.

The whole extra part is operated from here, an eastern annex of the adder read-out:


Spoiler (click to show/hide)

When looking at the operative abilities, the Marble Bookkeeper's precision in subtraction and multiplication is quite poor - 'low', with maybe 40% done towards medium. I'm being magnanimous when looking at multiplication, assuming that precision here should take into account the products that can be derived, not the factors taken as base.

EDIT - probably final update on this calculations stuff:

I ran the same calculation as above, 42 - 81, and this was the result:
(EDITedit: i later noticed i hadn't returned the 'reset' lever of the 1-bit to closed. This theoretically _shouldn't_ have any effect, but i ran the calculation again anyway and got the proper result there, as well)



Yay! The solution was indeed sending an extra 'subtract' signal to the processing memory, through this contraption (made much more confusing by space contraints):



The ramp opening in the upper northwest corner is the mouth of a N-S booster pit, covered by a hatch activated by the 'negative overflow' plate (actually, the latch which reacts to the overflow plate, so as long as the top bit and the connected latch haven't been re-set the hatch may remain open). In addition, it's activated by the normal subtraction starter signal, which also operates the malachite hatch straight east and the marble hatch directly south of the single pillar, the 'original' start location. When the overflow bit is set, the northwestern hatch is open, the cart leaves to the south, enters the eastern pit and, if the hatch is closed (because it's the overflow and not the start that sent the signal), it bounces back out, around the corner, over the plate, sending the 'subtract' signal and onto the secondary starting location. If the malachite hatch is open at well, the cart just starts the course directly without touching the plate.

EDIT to the third: Ahahaha, i browsed through some of the older dwarfputing threads and their wikipedia links and it seems i kind of re-invented the two's complement for handling of negative numbers in binary and applied it through a display hack. Well, it seemed just the way to solve the problem of negative results in subtraction...
« Last Edit: August 02, 2013, 08:35:27 pm by Larix »
Logged

Di

  • Bay Watcher
    • View Profile
Re: The ridiculously overblown abacus
« Reply #11 on: July 30, 2013, 12:55:21 am »

Rather impressive.
Logged
Quote from: Creamcorn
Dwarf Fortress: Where you meet the limit of your imagination, moral compass, sanity and CPU processor.
http://www.bay12forums.com/smf/index.php?topic=103080.0 Fix sober vampires!
http://www.bay12forums.com/smf/index.php?topic=91442.0 Dwarven Cognitive Science