NAND Patch

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post by Wolf01 »

Owen wrote:-> deifne: It was temporary; I'm moving it to a patch option
i already moved it, just dl my patch and use it
meowsqueak
Engineer
Engineer
Posts: 48
Joined: 05 Jul 2006 22:25

Post by meowsqueak »

Oh, sweet sweet goodness... geek++ :D
DredFurst
Engineer
Engineer
Posts: 7
Joined: 06 Jun 2006 16:45
Contact:

Post by DredFurst »

1 statement:

OpenTTD Does electronics simulation
meowsqueak
Engineer
Engineer
Posts: 48
Joined: 05 Jul 2006 22:25

Post by meowsqueak »

DredFurst wrote:1 statement:

OpenTTD Does electronics simulation
Not really, it does asynchronous logic simulation, and with some considerable track-laying could also do synchronous logic. You might also think of the number of trains passing a point in unit time as some sort of 'current'. It does not model electronics because there's no way to represent complex impedances (if you want to consider restriction of train flow as resistive, there's still no way I can see to model inductive or capacitive impedances, as there's no way to integrate or differentiate the current flow), amongst other things.

There's also no clear way to model potential difference, except with the speed of a train, maybe...

I think the analogy starts to break down.

The useful thing about this stuff is it lets you create much more complex systems, where one part of track can influence the operation of another. The NAND function is the basic building block of this. A lot of digital logic can now be implemented with tracks and trains, but it remains to be seen what sort of useful transport-related control structures people can come up with.

Exciting patch.
iNVERTED
Route Supervisor
Route Supervisor
Posts: 387
Joined: 24 Apr 2005 21:21
Location: Torquay, England
Contact:

Post by iNVERTED »

I appreciate your work and all... but surely programmable signals would be far better than any number of extra pre-signals - they would remove the need for laying un-used track, so we can make things more compact ;)

edit: regardless of that, I just found a place in my game where a NAND would be very, very useful.
User avatar
Rens2Sea
Engineer
Engineer
Posts: 109
Joined: 13 Sep 2004 10:22
Location: Holland
Contact:

Post by Rens2Sea »

Got nothing to do with this weird patch, but it's also with a little train that regulates the traffic.


Edit: fixed and added a funny maglev one, both 2 trains left - 2 trains right etc.

If you move the two-way signal from the maglev choohoo, you can change the amount of trains per branch at a time, atm it's 2-2, but can be set to 4-1 or something :O
Attachments
Rens Experiment, 27th Dec 2066.png
Little choochoo delaying the maglev :O
(194.36 KiB) Downloaded 635 times
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Post by skidd13 »

The patch is awesome!!!! I updated it against trunk with some minor changes.

EDIT: Added Savegame with the logic gates (OR,AND,NAND,NOR,XOR,XNOR).
Attachments
NAND_signal.patch
(8.84 KiB) Downloaded 231 times
nand.sav
savegame (nightly)
(184.47 KiB) Downloaded 196 times
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
ddream
Engineer
Engineer
Posts: 68
Joined: 28 May 2006 09:21
Location: 52° 13' N 21° 2' E

Post by ddream »

I've updated this patch to MiniIN 7267 and made graphic for nand signals, this graphic is necessary to run patched game. It is my first approach to OTTD sourcecode, so I could made something wrong.
Attachments
nnandw.grf
Nand signals grf (red)
(1.58 KiB) Downloaded 209 times
Nand-MiniIN-7267.patch
Nand signals MiniIN patch
(11.99 KiB) Downloaded 167 times
User avatar
mamuf
Engineer
Engineer
Posts: 33
Joined: 30 Mar 2007 21:31
Location: Prague, CZ

Post by mamuf »

I was playing around with Situation Switcher (found the idea at OpenTTDCoop) and made few pretty good and functionable variations. But I still knew something like NEG/NAND presignal would be handy to make it really perfect.

Then I tried to make my own NEG presignal but I could hardly understand the OTTD code around signals, although it actually worked. The main problem was the looping of these negations and the game has always freezed so I stopped trying for that time.

And then I found this thread after I saw a mention about NAND gates in the thread about programmable signals. Does anybody still work on this patch? And there is no activity in the other thread either :-(.
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post by Wolf01 »

i know that owens come out again some days ago with this idea, and he was thinking about making all signals become red when looping
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Post by skidd13 »

I rewrote the nand patch. Technicaly it works, but I have the feeling that something is wrong with it.

TODO:
- Savegame conversion to be save with the semaphores
- New sprites for the nand signal
Attachments
nand_new_r10462.patch
(6 KiB) Downloaded 109 times
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
User avatar
mamuf
Engineer
Engineer
Posts: 33
Joined: 30 Mar 2007 21:31
Location: Prague, CZ

Post by mamuf »

skidd13 wrote:I rewrote the nand patch. Technicaly it works, but I have the feeling that something is wrong with it.

TODO:
- Savegame conversion to be save with the semaphores
- New sprites for the nand signal
I am just working on it, too. I used a patch made from the 7267 MiniIN and merged it with the latest trunk manually but it has some issues, too. I think it is somewhere around signal bits because the game thinks I have looped NANDs and the ctrl-driven signal editing doesn't work well. (It is very similar to the first problems I've encountered while I was working on my own NEG signals.)

Now I'll have a look at your version, skidd13.
User avatar
mamuf
Engineer
Engineer
Posts: 33
Joined: 30 Mar 2007 21:31
Location: Prague, CZ

Post by mamuf »

I merged my nand-update and the one by skidd13 and now I'm going to test it. The one I updated is the one which checks the NAND-loop count so I think it will be better. But there were some weird constructs so I used some pieces of code by skidd13.
User avatar
mamuf
Engineer
Engineer
Posts: 33
Joined: 30 Mar 2007 21:31
Location: Prague, CZ

Post by mamuf »

So there it is. But it still yells that some NAND signals are looped. And the signals behave weird at all. I think it is still somewhere within the signal bits.

EDIT: I fixed some little glitches and it seems to work now. The only thing I am not sure about is the value for argument 'from' on the line added to settings.cpp.

NOTE: The savegames are most likely incompatible.
Attachments
nand_new_r10462_v2.patch
some fixes, now it works better.
(11.71 KiB) Downloaded 129 times
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Post by skidd13 »

mamuf: small hint there's an edit button, so please don't double post until it might be necessary. ;)

I removed the loop stuff cause the warning sucks. What about a debug message (to the console) after a code preset value e.g. 20.
The loop is caused by the original pathfinder which is AFAIK still used for the signal handling. So a debug message to the console should be enough.

The savegame value in your settings.cpp is wrong. Should be 70 ATM. (Savegame bump needed).
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
User avatar
mamuf
Engineer
Engineer
Posts: 33
Joined: 30 Mar 2007 21:31
Location: Prague, CZ

Post by mamuf »

Yep, I already edited the last post while I had fixed version. But maybe I should've better edit the last but one :wink:

Since the NAND sets itself red while the NAND-loop reaches it's limit, the warning is really useless. I agree that if this won't be merged with trunk it doesn't need any GUI. The DEBUG call is already at line 1773 in rail_cmd.cpp. Originally it was made with printf and someone wrote here it should be DEBUG only so I changed it but I am not sure about the values of the arguments:

Code: Select all

DEBUG(misc, 0, "NOTICE: Broken off processing, found too many NAND signals\n");
So you suggest the loop check should have hardcoded limit? Maybe it still could be a patches' variable because it is used at to places in the code.
User avatar
skidd13
OpenTTD Developer
OpenTTD Developer
Posts: 522
Joined: 03 Mar 2005 10:49
Location: Germany

Post by skidd13 »

mamuf wrote:... but I am not sure about the values of the arguments:

Code: Select all

DEBUG(misc, 0, "NOTICE: Broken off processing, found too many NAND signals\n");
misc -> section of debug, misc seems to be OK IMO
0 -> debug_level, IIRC 0 is show message allways
"<string>" -> no need of declaration
mamuf wrote:So you suggest the loop check should have hardcoded limit? Maybe it still could be a patches' variable because it is used at to places in the code.
The multiple usage is no reason to create a patch value.
Attachments
nand_new_r10467.patch
(7.68 KiB) Downloaded 122 times
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
User avatar
AlexW
Traffic Manager
Traffic Manager
Posts: 213
Joined: 20 Feb 2007 07:59
Location: Newbury, UK

Post by AlexW »

If it is possible for someone to explain this in village idiot/simpleton/layman's terms, I would be most appreciative. I simply can't get my head around the usage of NAND, even with the picture(s) that have been posted!
Hooked on Transport Tycoon since 1994
User avatar
mamuf
Engineer
Engineer
Posts: 33
Joined: 30 Mar 2007 21:31
Location: Prague, CZ

Post by mamuf »

AlexW wrote:If it is possible for someone to explain this in village idiot/simpleton/layman's terms, I would be most appreciative. I simply can't get my head around the usage of NAND, even with the picture(s) that have been posted!
The question is - Do you know what logic gates are in general? Logic gates like AND, OR, NOT and ohers? If not, read the wikipedia article for example: Logic gate.

NAND is simply gate made of NOT and AND. Written in functional manner it looks like: NOT(AND(x, y)), where x, y are logic variables (values 1|0). In common electronics NAND is the simpliest gate in the meaning of number of transistors needed to build such gate. Other gates need more of them to be build. And you can build every single known logic gate of NANDs only.

Logic table for NAND:

Code: Select all

x y | NAND(x, y)
--------
0 0 | 1
0 1 | 1
1 0 | 1
1 1 | 0
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

I see this thread for the first time (how could I have missed this... :? ).

OpenTTD reaches a whole new level of geekdom! :lol: This is awesome stuff. :D
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 6 guests