LED counter

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

Moderator: OpenTTD Developers

Tjark
Engineer
Engineer
Posts: 5
Joined: 12 Jun 2008 13:34

Re: LED counter

Post by Tjark »

This is awesome, very well done! I am thinking about the posibilities atm, what about a self regulating network :shock:

Example:

- Power station (a)
- Coal mines (b and c)
- Trains (<\> = network direction)
- Presignaling according to a memory track ( ! )

..................................................
.________<___[--a--]_____.....
/............................................\...
|.............................................|..
.\!______[--b--]_____>____/...
...\_____________[--c--]__/.....
..................................................

Each train has the orders to drop all cargo at the power station and thats it, no pick up orders what so ever. After it has finished the drop off, it moves on the mainline and starts heading to the power station to drop off again! But this is were the fun starts, the network forces the train to move to one of the two coal mines before it reach the power station again. The network makes the track descision by checking a bit (train) that says 1 if there is allready a train heading to/in the station or 0 if there is no train yet on that part of the track. When the train reaches the station it will autopick the coal thats waiting and move on.

I dont have this working yet, but it unlocks some cool posibilities, however dont expect some clean networking ;). I like the idea of simply unleaching some trains on the network with only 1 order to get them into action, and let the network do the job!

btw: when I give a train really no orders, the pathfinding doesnt seem to check the signals ahead. example: The moment a train reaches a T junction he randomly picks an option not looking at the next signal, so a sec after he chose the path he can stand still because the next signal has been red all the time... Is there a way to avoid this stupid behaviour when without using orders?
Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

Re: LED counter

Post by Igloo »

Hertogjan: the savegame uses a half-adder to count. Once you have the basic logical gates building an adder is not that hard a task (it is quite cumbersome though). The commented save game contains isolated examples of the gates (AND, OR and NOT). Using those it is possible to make an adder, which indeed is quite large and very, _very_ slow ;-P.

Tjark: it would be realy cool if those gates could be used in a meaningful network :D.
if triangles had a god, He would have three sides
Caesius
Engineer
Engineer
Posts: 10
Joined: 12 Jun 2008 22:00

Re: LED counter

Post by Caesius »

So who's willing to build a complete ALU that can accept user input in the form of ordering trains to proceed without signals?
User avatar
osai
Traffic Manager
Traffic Manager
Posts: 132
Joined: 22 Sep 2004 14:56
Location: 10.0.1.254
Contact:

Re: LED counter

Post by osai »

Hello Igloo,

that is really amazing what you did. I think #openttdcoop will be able to use the gates, I already shrunk the size of the gates to make them react faster. I think this is the main problem of the gates. The delay could cause jams because the state of the output is not changing at the same time as the input changes.

Anyway I really like your work and it reminds me of a a shiftback system, I created. I'll have a closer look at your circuit and maybe try some things on my own.

p.s.: it looks like you mixed the signs of the logic gates in your commented savegame -> the ORs should be ANDs and the AND should be an OR gate (at your half adders).


Best Regards,
Osai
Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

Re: LED counter

Post by Igloo »

Hey osai,

thanks for the reply. I've read some of the articles on openttdcoop over the past weeks, I never expected people were that busy with this game =].

The speed is indeed a problem. This can be solved partly by smaller trains and partly by smaller gates. It is probably possible to make gates that are fast enough to be used in a network. Provided that the trains used in the network are not too small.

The labeling in the comments is as intended. It al depends how you define the 1's and 0's. I used: green light is a 1, red light is a 0. You probably looked at it the other way around.

I'm curious as to what your take is on these gates.

Igloo
if triangles had a god, He would have three sides
User avatar
osai
Traffic Manager
Traffic Manager
Posts: 132
Joined: 22 Sep 2004 14:56
Location: 10.0.1.254
Contact:

Re: LED counter

Post by osai »

Igloo wrote:The labeling in the comments is as intended. It al depends how you define the 1's and 0's. I used: green light is a 1, red light is a 0. You probably looked at it the other way around.

I'm curious as to what your take is on these gates.

Igloo
I really looked at this vice versa and still do. I am still working on this topic and will publish first results soon.
VoxDissident
Traffic Manager
Traffic Manager
Posts: 178
Joined: 09 Apr 2008 01:37

Re: LED counter

Post by VoxDissident »

Wow... Brilliant and ridiculous. I am very impressed... and somewhat disgusted.

:)

-Vox
User avatar
osai
Traffic Manager
Traffic Manager
Posts: 132
Joined: 22 Sep 2004 14:56
Location: 10.0.1.254
Contact:

Re: LED counter

Post by osai »

Hello all,

I finally posted my report about logic gates (@ openttdcoop.org). Enjoy Reading. Part 2 will follow soon.
Tjark
Engineer
Engineer
Posts: 5
Joined: 12 Jun 2008 13:34

Re: LED counter

Post by Tjark »

Really great job!! I am looking forward to part2! I am still strugling to get these gates to work in a normal network and really do something usefull, but I have made a somewhat decent loadbalancer with them allready!

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

Re: LED counter

Post by Igloo »

Nice article Osai, though it is confusing as hell to see you reverted the meanings of the 0 and 1 ;-). That design of the OR gate is quite efficient.
Hereby an implementation of the NOT-gate using a different idea. it should be faster (did you compute those speeds, if so, how?).
Attachments
NOT2.PNG
NOT2.PNG (23.36 KiB) Viewed 6379 times
if triangles had a god, He would have three sides
Tjark
Engineer
Engineer
Posts: 5
Joined: 12 Jun 2008 13:34

Re: LED counter

Post by Tjark »

Image

Trains are balanced between 2 mines by using a NOT load balancer with a memory track
User avatar
osai
Traffic Manager
Traffic Manager
Posts: 132
Joined: 22 Sep 2004 14:56
Location: 10.0.1.254
Contact:

Re: LED counter

Post by osai »

Interesting solution for NOT, Igloo. Indeed it might be a little bit faster, but I also searched for the minimum size. I calculated the reaction times using a screen-recorder with an correctness of 1/25s :) I could make it more detailed though, but I am not sure how often the OpenTTD screen is redrawn per second. I'll talk about speed of logic gates in Part II.

I am still not sure, if I just mixed the definition of green/red, 0/1. Because you construction for OR seems not be a or. Of cause changing the definition turns AND in OR or vice versa, but the logic of the OpenTTD signals, which is hardcoded, doesn't change.
Can you please sign the input and output of your OR construction in your led counter savegame.
Another question: Did you use rs-flipflops for saving the binary state of your counter or is it just a hacky construction?

Regards,
Osai
Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

Re: LED counter

Post by Igloo »

Nice one, Tjark =]

Osai:

It is fun to play around with those constructions. Unfortunately those double loops takes quite a bit of space.

Indeed the OR you use is equivalent to my AND and vice versa. In the commented save game each gate is build separately in the northernmost corner. All gates there have the input in the north and the output to the south.

The memory is not a RS flipflop. The problem with the system is that there is no clock pulse. Hence a more difficult construct is used. It was thought out on the spot, but looking at wiki it is a Master-slave D flip-flop.
if triangles had a god, He would have three sides
Caesius
Engineer
Engineer
Posts: 10
Joined: 12 Jun 2008 22:00

Re: LED counter

Post by Caesius »

Am I the only one who noticed the LED counter goes 1 - 2 - 7 - 4 - 5 - 6 - 1 (I think) or is it just me?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: LED counter

Post by planetmaker »

Caesius wrote:Am I the only one who noticed the LED counter goes 1 - 2 - 7 - 4 - 5 - 6 - 1 (I think) or is it just me?
It's just you :P
No, I made the same observation with a savegame I downloaded a few days ago.
Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

Re: LED counter

Post by Igloo »

That is true for one of the versions :cry: . The trains on the main railline where not synced correctly. When they are synced the counter does work as intended
if triangles had a god, He would have three sides
User avatar
Pixelz
Engineer
Engineer
Posts: 2
Joined: 10 Apr 2006 11:15

Re: LED counter

Post by Pixelz »

I've made a faster NOT gate based on the one Igloo posted. It's main feature is that the trains (hopefully) doesn't stop moving. It does take up a bit more space but I didn't really try to make it small. It's probably possible to make one that's smaller and even faster.
Attachments
looping_not_gate.png
looping_not_gate.png (39.1 KiB) Viewed 5531 times
Mark0291
Engineer
Engineer
Posts: 7
Joined: 30 Jun 2008 18:27

Re: LED counter

Post by Mark0291 »

Hello,
After reading what Tjark said about making a self regulating network i figured it would be possible and came up with this network using NOT-Gates, memory cells and some dummy trains. What it does is making sure there is always a train waiting to enter the loading station. It also takes a train of the network if there are too many and adds a new train every month.

EDIT: Save is made using OTTD 0.6.0
Attachments
selfregnw.sav
(403.35 KiB) Downloaded 314 times
Igloo
Engineer
Engineer
Posts: 14
Joined: 19 May 2008 23:28

Re: LED counter

Post by Igloo »

Nice one, Mark! I've tried to figure it out, but I didn't think of this solution. Maybe it is possible to make this viable for a big network =].

Pixelz: I tried to copy your gate on my PC, but I can't get it working. When the input is green the train keeps running both the inner and outerloop, see picture.
Not_Pixelz.PNG
Not_Pixelz.PNG (61.33 KiB) Viewed 5362 times
if triangles had a god, He would have three sides
User avatar
Pixelz
Engineer
Engineer
Posts: 2
Joined: 10 Apr 2006 11:15

Re: LED counter

Post by Pixelz »

I've made a working example. The train sometimes loop like you described but it doesn't cause any flickering so it's all good.
Attachments
not gate.sav
(22.64 KiB) Downloaded 188 times
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 14 guests