LED counter

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

LED counter

Post by Igloo »

While playing this game, messing around with train signals, I wondered whether it was possible to create electronic circuitry with the help of signals, trains and tracks. After several days of trial and error, the attached save game is the result.
In short: I have made a ´LED´ display that counts the amount of times a train passes a certain track (see image, showing the number 3). At this moment the display will only count to 7, and then reset.

In terms of efficiency, we're doing not so well: the display takes a couple of days to update, which gives it a clock speed of approximately 0.000002 Hertz (consider that regular computers are into the gigaherz range).
LED.png
LED.png (27.19 KiB) Viewed 25331 times
This savegame runs on the latest stable build of OpenTTD (0.6.1.0).

Check it out :)
Attachments
Iglandir2.sav
(705.83 KiB) Downloaded 1739 times
if triangles had a god, He would have three sides
User avatar
Core Xii
Traffic Manager
Traffic Manager
Posts: 228
Joined: 08 Apr 2008 09:47
Location: Finland

Re: LED counter

Post by Core Xii »

That's wicked, but how about a little closer zoom screenie?
broodje
Director
Director
Posts: 615
Joined: 13 Jul 2003 12:47
Location: Alphen aan den Rijn
Contact:

Re: LED counter

Post by broodje »

You sir.... you've got way to much time on your hands! Incredible fun to watch. It took me some time to find out where the clock was though, I hadn't noticed the passenger line was such an important part of the design. Show's quite well that conditional orders aren't needed to make a nice switch board, or should I regard your design as 'too low level' to be usable? ;).
moki
Traffic Manager
Traffic Manager
Posts: 131
Joined: 06 Jul 2007 08:48
Location: Wismar, Germany

Re: LED counter

Post by moki »

I guess, the "computer" could be made slightly faster by using maglev trains in the switches as well as in the "display", though I still don't know how exactly this thing works after staring at it for ten minutes... :shock: quite impressive, to say the least...
Tom0004
Chairman
Chairman
Posts: 822
Joined: 01 Jul 2007 22:33
Location: Manchester, UK

Re: LED counter

Post by Tom0004 »

This is some what mad.

Well done !! 8)
zypa
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 30 Mar 2006 12:05
Location: Germany
Contact:

Re: LED counter

Post by zypa »

This is sick ;)
How much time did you "waste" on this savegame?
User avatar
AntBUK
Transport Coordinator
Transport Coordinator
Posts: 319
Joined: 02 May 2007 12:29
Location: Sheffield, England
Contact:

Re: LED counter

Post by AntBUK »

Sounds like somebody needs to discover a copy of WireWorld...
Rasing Awareness: Aspergers Syndrome 1 (NAS UK)2 (BBC)3 (YaleDDC)


Something is driving you insane... It is me.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: LED counter

Post by Roujin »

Interesting.. I've started to make some comments on it with signs, but I've given up on the magic that's happening in the east oO It's too late right now for such things :shock: here's my commented save file for those who are interested in it.

Unfortunately I've done it with trunk, not 0.6.1, so you'll need trunk/nightly too to load it...

Here's also a screenshot.
Attachments
LED comments.png
comments by me. Work by Igloo. ;)
(66.01 KiB) Downloaded 1655 times
Iglandir2 comments.sav
The savegame. Made with r13419.
(707.02 KiB) Downloaded 947 times
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Draakon
Director
Director
Posts: 542
Joined: 11 Mar 2007 16:50

Re: LED counter

Post by Draakon »

So what this does is count how many trains pass on a certain line?
Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

Re: LED counter

Post by Igloo »

Thanks for all the replies, and yes I am slightly mad ;-). This project took several days of slow and steady improvement.

The savegame contains a network that counts the trains that pass from east to west along the maglev line. However, it does take quite some time to update because the network is quite slow. Updating the system to maglev is possible, however, when I did that not all gates worked correctly so I stuck with railroad.

Roujin: you deciphered it correctly =]. Tonight after work and soccer I'll post a version including more details.
if triangles had a god, He would have three sides
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: LED counter

Post by Roujin »

Igloo wrote:Thanks for all the replies, and yes I am slightly mad ;-). This project took several days of slow and steady improvement.

The savegame contains a network that counts the trains that pass from east to west along the maglev line. However, it does take quite some time to update because the network is quite slow. Updating the system to maglev is possible, however, when I did that not all gates worked correctly so I stuck with railroad.

Roujin: you deciphered it correctly =]. Tonight after work and soccer I'll post a version including more details.
Looking forward to it. I didn't really get the rest (where I didn't place signs) yesterday, e.g. why there's two 3-bit numbers, of which one is increased as soon as the passenger train reaches the point I've labelled "start of mechanism", and the other is adapted to what the first one holds as soon as the passenger train reaches the point "checkpoint 1".
Also the eastern part which probably counts up by one and then handles overflows and such was too confusing for me to be understood in each detail :? I also failed to understand what your structures there using trains with ~3 wagons exactly do.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: LED counter

Post by CommanderZ »

That's awesome. I had to laugh when I was looking at the refreshing display.

Btw, couldn't "tunnels can cross each other" cheat make your work easier?
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Re: LED counter

Post by Frostregen »

Impressive :)
Reminds me of the old NAND-Signals Patch ;)
Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

Re: LED counter

Post by Igloo »

After playing this game for a while it became clear that the signals are very powerful. Which led me to wonder whether it is possible to build all logical gates in openTTD using only trains and signals. From there on it went downhill. The attached save game is the same save game I posted previously, but now with lots of comments.

Overview of the logic gates
In the system a green sign represents a value of 1 and a red sign represents a value of 0.

The OR gate is trivial:
OR.PNG
OR.PNG (19.74 KiB) Viewed 23997 times
The AND gate is not quite so simple. When the first train stops before the sign near Bit I or Bit 2 the presignals send the second train through the checkpoint. This turns the output to red. If both Bit I and II are green the trains will never go through the checkpoint.
NOT.PNG
NOT.PNG (23.1 KiB) Viewed 24011 times
The NOT gate was the hardest. By using a combination of presignals and standard signals it was possible to keep one piece of track occupied continuously if the input is green.
The attachment NOT.PNG is no longer available
The memory is simple in itself. However because the system does not use a clock-pulse it became more complex. To work around this problem the memory stores it's state internally before the output is updated. Hence two trains for each bit.

The other parts of the system are large combinations of ORs to convert binary numbers to decimal and to update the LED display on basis of the decimal value.
if triangles had a god, He would have three sides
Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

Re: LED counter

Post by Igloo »

Apparently only three files can be included in a post :?
Attachments
Iglandir comments.sav
(708.15 KiB) Downloaded 798 times
if triangles had a god, He would have three sides
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Re: LED counter

Post by XeryusTC »

I've tried to do the logic gates too one day, OR is not so hard as it is the default of presignals. AND becauses a bit harder but isn't that hard to get as you can simply add an extra signal IIRC, it has been a while though.
I think I never got the NOT gate to work although I fiddled quite a bit with it.
I also remember having completed another logic gate but I don't know which one.

Kudos on the LED counter though, I haven't looked at it but it sure seems like it took you A LOT of time and thinking to make it work.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: LED counter

Post by Ammler »

OMG, that is crazy! ;-)

Nice to see, someone reached to make a NOT and AND (NAND) without patching: http://www.tt-forums.net/viewtopic.php?f=33&t=26364


Greets
Ammler
User avatar
flake
Engineer
Engineer
Posts: 66
Joined: 28 Apr 2004 10:07
Location: Salzburg
Contact:

Re: LED counter

Post by flake »

crazy :o

thank you for amazing me.
*<(:-}
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: LED counter

Post by Roujin »

Thank you for posting the commented version. Now I also understand the eastern part. Who would have thought that these wacky constructions with the waypoints are nothing else than AND-gates? 8) Great job on managing to build them! :)

edit: now, how long will you take to build a turing machine out of rails, and emulate OpenTTD on it? :lol:
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
hertogjan
Director
Director
Posts: 560
Joined: 03 Jan 2006 20:45
Location: Netherlands

Re: LED counter

Post by hertogjan »

This is really nice :)
It reminds me of a similar program I once programmed in QBasic, which basically was a binary adder (the thing that adds two numbers, not the snake) using a train and a lot of switches. If one figures how to make the switches work reliably in OpenTTD, then one could make a binary adder in OpenTTD as well, although it will be quite large, I guess.
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 5 guests