<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>#openttdcoop &#187; Logic Gate</title>
	<atom:link href="http://blog.openttdcoop.org/tag/logic-gate/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.openttdcoop.org</link>
	<description>The #openttdcoop and OpenTTD Blog</description>
	<lastBuildDate>Thu, 26 Aug 2010 19:06:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Stochastic Networks</title>
		<link>http://blog.openttdcoop.org/2009/09/06/stochastic-networks/</link>
		<comments>http://blog.openttdcoop.org/2009/09/06/stochastic-networks/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 11:42:40 +0000</pubDate>
		<dc:creator>Combuster</dc:creator>
				<category><![CDATA[Public Server]]></category>
		<category><![CDATA[Logic Gate]]></category>
		<category><![CDATA[NewGrf]]></category>
		<category><![CDATA[OpenTTD]]></category>
		<category><![CDATA[Signalling]]></category>
		<category><![CDATA[Stochastic Network]]></category>
		<category><![CDATA[Trains]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://openttdcoop.org/?p=574</guid>
		<description><![CDATA[You will probably have seen, or participated, in the last Public server game, which was all about logic. I&#8217;ll try to explain it in a bit. After recent interests in self-regulating construction, there was an attempt to improve the usability of such designs. We have already seen self-regulating networks, where dummy trains transfer cargo onto [...]]]></description>
			<content:encoded><![CDATA[<p>You will probably have seen, or participated, in the last Public server game, which was all about logic. I&#8217;ll try to explain it in a bit.</p>
<p>After recent interests in self-regulating construction, there was an attempt to improve the usability of such designs. We have already seen self-regulating networks, where dummy trains transfer cargo onto ML trains, and recently self-regulating orders where vehicles could potentially go to all stations. What has not yet been done is to apply a form of regulation to point-to-point passenger games.</p>
<p><span id="more-574"></span></p>
<p>The main idea behind the concept is to have trains arbitrarily choose a station to drop their next load. While one could put each possible pair of stations into an order list, you would have to maintain the 240 possible pairs  for 16 stations, making it a big hassle. However, if you force trains in a certain direction by the network, you can keep everything more manageable. So if you can force a certain selection of trains in one direction, you are set.</p>
<div id="attachment_580" class="wp-caption alignnone" style="width: 437px"><a class="image-link" title="The Plan" rel="shadowbox;width=1280;height=968;" href="http://blog.openttdcoop.org/files/blog/2009/09/metropqyq.png"><img class="size-full wp-image-580" title="PSG #157 plan" src="http://blog.openttdcoop.org/files/blog/2009/09/metropqyq.png" alt="The plan for PSG #157" width="427" height="323" /></a><p class="wp-caption-text">The plan for PSG #157</p></div>
<p>In PSG #157, the idea was put to the test. The plan basically consisted of four flattened rings, where trains would be able to change on the shared parts. At three of the hubs, trains would have a choice of turning right or left. Using logic, trains were forced either left or right in turn. The two smaller hubs used flip-flops to do perfectly cut the train flow in half for each outer part. Due to the size of a flip-flop, the central hub was built using a timer. This timer forced all trains to the left for a few seconds, then right for the next few seconds, which again resulted in the stream being effectively cut in half.</p>
<p>Stations would need a much lower ratio &#8211; if they would get a 50/50 share, the chance was very likely that the train would drop the load at the next stop, and the chance of reaching the other end of the network would be minimal. Instead each station was given 1/8th of the traffic, which gave a good distribution without having the trains spending an eternity on the line. Due to traffic being halved, the outer hubs would take 1/4 trains each.</p>
<div id="attachment_580" class="wp-caption alignnone" style="width: 437px"><a class="image-link" title="Main Station Hub 2" rel="shadowbox;width=1280;height=968;" href="http://blog.openttdcoop.org/files/blog/2009/09/Metropolis-16th-Aug-23472.png"><img class="size-full wp-image-577" title="Metropolis, 16th Aug 2347" src="http://blog.openttdcoop.org/files/blog/2009/09/Metropolis-16th-Aug-23472.png" alt="quarterselector" width="427" height="323" /></a><p class="wp-caption-text">Station hub 2, where you can see the 1/4 selector</p></div>
<p>To pick one out of four or eight trains accurately, a mechanism was needed. The most used system consisted of a not gate (the MagLev loops at the top) which would allow the train in the counter (erail loops in the bottom) to move ahead one signal for each train. The loop had 4 signals, and thus four segments. By tapping into one of the segments, we could get a signal for every fourth train. The remaining pair of not gates (MagLev loops in the center) were used to always have one red signal and one green signal, so that trains couldn&#8217;t have second thoughts and still go the wrong way.</p>
<p>You can have a look at the game in the <a title="PSG #157" href="http://openttdcoop.org/wiki/PublicServer:Archive_-_Games_151_-_160#gameid_157" target="_blank" onclick="pageTracker._trackPageview('/outgoing/openttdcoop.org/wiki/PublicServer_Archive_-_Games_151_-_160_gameid_157?referer=');">PublicServer Archive</a></p>
<p>As a special feature, there were new logic trains available. Going at supersonic speeds, they allowed the user to create extremely fast responding logic systems, and made completing the plan a lot easier. You can find them in OpenTTD&#8217;s online content section.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.openttdcoop.org/2009/09/06/stochastic-networks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Optimization of Logic &#8211; Logic Gates [Part II]</title>
		<link>http://blog.openttdcoop.org/2009/01/18/optimization-of-logic-logic-gates-part-ii/</link>
		<comments>http://blog.openttdcoop.org/2009/01/18/optimization-of-logic-logic-gates-part-ii/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 23:31:29 +0000</pubDate>
		<dc:creator>Osai</dc:creator>
				<category><![CDATA[Community News]]></category>
		<category><![CDATA[OpenTTD]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Logic Gate]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://blog.openttdcoop.org/?p=503</guid>
		<description><![CDATA[Almost half a year ago I blogged about Logic Gates and already the headline promised that this story is not over yet. Now, I was finally able to concentrate my thoughts about logic gates again and was able to optimize the gates again. As I pointed out earlier the reaction time is too long and [...]]]></description>
			<content:encoded><![CDATA[<p>Almost <a href="http://blog.openttdcoop.org/2008/06/17/the-insane-led-counter-logic-gates-part-1/">half a year ago I blogged about Logic Gates</a> and already the headline promised that this story is not over yet. Now, I was finally able to concentrate my thoughts about logic gates again and was able to optimize the gates again. As I pointed out earlier the reaction time is too long and gates are reacting too sluggish. The slow processing made the gates only interesting in places which don&#8217;t need to be fast. For example the timing of injection. But when it comes to mainlines, sidelines, station entries and many other fancy coop-ish constructions they were more an impediment.<br />
<strong><a href="http://blog.openttdcoop.org/files/osai/logic_train.grf">Download Logic Train NewGRF</a></strong></p>
<p>I hope, this&#8217;ll change now, because these new constructions require only one train without any wagons and are extremely small in comparison with the old gates and the once I see nowadays in our games.<br />
<span id="more-503"></span></p>
<h3>The Logic Train</h3>
<p>Especially for faster gates Ammler created a NewGrf for me which replaces MagLev &#8220;Lev3 Pegasus&#8221; with a &#8220;Logic Train&#8221;. This trains has a max. speed of 65,918km/h and 65,535hp. In fact insanely fast and accelerating from zero to max speed instantly. The optimized gates also function with normal trains but are not as fast as with the Logic Train and sometimes the evil chooser problem occurs. This somehow doesn&#8217;t happen with the Logic Trains, but don&#8217;t ask me why. Of course you can download the grf file I used. You&#8217;ll need it. As far as I know it is also planned to add a NewGrf file to the #openttdcoop NewGrf Package with certain restrictions. In fact, you are not allowed to add wagons to the train. Lets see if that&#8217;s possible.</p>
<h3>The Not Gate</h3>
<p><img src="http://blog.openttdcoop.org/files/pictures/logic_gates/logic_gates_pt2_not_gate.png" width="400" height="400" alt="New Not Gate" title="New Not Gate" /><br />
My new NOT-Gate creation has a size of 3&#215;4 tiles. That&#8217;s only three tiles bigger than the smallest circle in which a train can drive. The reaction time is close to zero. The gate requires a <em>logic train</em> and a waypoint. The train needs the waypoint in the order list, otherwise it&#8217;ll not work as intended. As you can see the train has to make a choice. The problem we have in normal games, that the signal turns red in the moment the train wants to enter doesn&#8217;t occur. I don&#8217;t know why, but it just never happened to me, even in long-time tests.</p>
<p>In this video you can see a comparison to other gate types. The important gates has the Waypoint &#8220;C&#8221;. At the output comparison you can see its the fastest and always showing the opposite of the entering signal.<br />
<a href="/videos/comparison_not_gates.mp4">Optimization of Logic &#8211; Logic Gates [Part II]</a></p>
<h3>The Or Gate</h3>
<p><img src="http://blog.openttdcoop.org/files/pictures/logic_gates/logic_gates_pt2_or_gate.png" width="400" height="372" alt="The New OR-Gate" title="The New OR-Gate" /><br />
The OR-Gate requires the same things as the NOT-Gate. One <em>logic train</em>, a waypoint and an entrance in the order list. The reaction time is close to zero seconds too, you can see how it works in another video I created.</p>
<p><a href="/videos/or_gate_in_action.mp4">Optimization of Logic &#8211; Logic Gates [Part II]</a></p>
<h3>Conclusion</h3>
<p>I hope to see some awesome constructions of all the fans of <a href="http://en.wikipedia.org/wiki/Arithmetic_Logic_Unit" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Arithmetic_Logic_Unit?referer=');">ALUs</a> and logic construction. Since these gates are much smaller and react very fast the possibilities are almost inexhaustible. If you have an awesome construction, post it here, upload it to our wiki or send an email to info [at] openttdcoop.org. I am awaiting your creations.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.openttdcoop.org/2009/01/18/optimization-of-logic-logic-gates-part-ii/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The insane LED Counter &amp; Logic Gates [Part 1]</title>
		<link>http://blog.openttdcoop.org/2008/06/17/the-insane-led-counter-logic-gates-part-1/</link>
		<comments>http://blog.openttdcoop.org/2008/06/17/the-insane-led-counter-logic-gates-part-1/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 23:07:44 +0000</pubDate>
		<dc:creator>Osai</dc:creator>
				<category><![CDATA[OpenTTD]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Logic Gate]]></category>

		<guid isPermaLink="false">http://blog.openttdcoop.org/?p=414</guid>
		<description><![CDATA[While browsing tt-forums I stumbled upon a LED Counter created in an OpenTTD game. This is an amazing work because you require a basic knowledge about electronics as well as about OpenTTD and signaling. This work inspired me and I planned to do some other constructions. Of course this counter is a complex electronic circuit [...]]]></description>
			<content:encoded><![CDATA[<p>While browsing tt-forums I stumbled upon a <a href="http://www.tt-forums.net/viewtopic.php?f=29&#038;t=37902" onclick="pageTracker._trackPageview('/outgoing/www.tt-forums.net/viewtopic.php?f=29_038_t=37902&amp;referer=');">LED Counter created in an OpenTTD</a> game. This is an amazing work because you require a basic knowledge about electronics as well as about OpenTTD and signaling. This work inspired me and I planned to do some other constructions.<br />
<img src="http://blog.openttdcoop.org/files/pictures/logic_gates/led_counter_by_igloo.png" width="316" height="175" alt="LED Countr by Igloo" title="LED Countr by Igloo" /></p>
<p>Of course this counter is a complex electronic circuit and we should not look at it in a too close manner. It uses half-adders, memory and a lot of logic gates. But some parts, especially the <a href="http://en.wikipedia.org/wiki/Logic_gates#Symbols" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Logic_gates_Symbols?referer=');">logic gates</a>, are really interesting.<br />
My first intention was to optimize them to be useful in #openttdcoop network games.</p>
<h3>Logic Gates &#8211; An Overview</h3>
<p><b>Boolean Operators a.k.a. Signals</b><br />
First of all, we&#8217;ll have a look at the requirements to understand logic gates, as I create them, in OpenTTD. A default signal can be either <span style="color: red;">red</span> or <span style="color: green;" >green</span>. These two states can be defined as true and false or as 1 and 0 or zero and non-zero or easily as yes and no. In fact, <span id="more-414"></span>it is a <a href="http://en.wikipedia.org/wiki/Boolean" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Boolean?referer=');">system with only two states</a>. A <span style="color: orange">Maybe</span> doesn&#8217;t exist. As you can see it, doesn&#8217;t matter which state has which name, but it is important for the definition and further constructions.</p>
<p>My definition is:
<ul>
<li>0 / false / no = <b><span style="color: green;" >green</span></b></li>
<li>1 / true / yes = <b><span style="color: red;" >red</span></b></li>
</ul>
<p>That&#8217;s just a matter of the question you ask yourself. My question is: <em>Is a train in the signal block?</em>. The complete logic turns around if you ask yourself: <em>Is the track free?</em>.<br />
Please keep in mind that my definition is _NOT_ equivalent to the definition of &#8216;red&#8217; and &#8216;green&#8217; used in electronics. I still decided to do it this way, because the AND-gate is easier to build in this case and I somehow think it is used more often in complicated constructions like the XOR-gate.</p>
<p><img src="http://blog.openttdcoop.org/files/pictures/logic_gates/boolean_values.png" width="400" height="200" alt="Types and Values of Signals" title="Types and Values of Signals" /></p>
<p><b>Handling special cases</b><br />
You also should know, e.g. when you build your own logic gate construction, that I always used two trains to create it. One train and a signal block with more than one exit signal (-< =) is always vulnerable for a signal-lock-situation. In this case the train enters the block and while choosing a track, the chosen track and its signal turn red. The train is locked and it takes several seconds to return and choose the correct exit.<br />
I really like <a href="http://www.openttdcoop.org/wiki/Image:Notgate.png" onclick="pageTracker._trackPageview('/outgoing/www.openttdcoop.org/wiki/Image_Notgate.png?referer=');">Marks Idea<a></a> for a NOT Gate, but it might cause unintended problems. Using two trains avoids this problem because the first train stops and the train behind must always choose the other option which changes the state of the logic construction.</p>
<p><b>The best train</b><br />
I optimized all construction for two <a href="http://wiki.openttd.com/index.php/Lev3_%27Pegasus%27" onclick="pageTracker._trackPageview('/outgoing/wiki.openttd.com/index.php/Lev3_27Pegasus_27?referer=');">Lev3 &#8216;Pegasus&#8217;</a> (<a href="http://wiki.openttd.com/index.php/Maglev" onclick="pageTracker._trackPageview('/outgoing/wiki.openttd.com/index.php/Maglev?referer=');">Maglev</a>) and added sometimes a wagon to make the train a half-tile longer. Lev3 is better than <a href="http://wiki.openttd.com/index.php/Lev4_%27Chimaera%27" onclick="pageTracker._trackPageview('/outgoing/wiki.openttd.com/index.php/Lev4_27Chimaera_27?referer=');">Lev4</a>, because Lev4 for is accelerating too fast and both trains slow each other down all the time having a lower average speed than Lev3. All slower trains (482km/h for Lev3) work too, but the reaction time is slower.</p>
<h3>The AND-Gate</h3>
<p>I told you a lot about the requirements now and unluckily the first logic gate is very simple. The feature of AND logic is hardcoded in OpenTTD (all entrance-exit-blocks work that way) and we don&#8217;t have to add further additions to this signal block.<br />
<img src="http://blog.openttdcoop.org/files/pictures/logic_gates/and_gate.png" width="400" height="213" alt="AND-gate" title="AND-Gate" /><br />
What happens here is easy, as the logic table shows you only if both signals (x, y) have the same (1) state the output (x^y) is (1). In other (easier) words x and y have to be red to turn x^y red as well.</p>
<h3>The NOT-Gate</h3>
<p>The NOT gate returns always the opposite of the input. Two trains, the loop and a prio-line were needed to create this construction. It looks a bit like a maze, because I shrank the size as much as possible. For this construction you need two Lev3 with one wagon or two double Lev3 to work properly. If you don&#8217;t the output might turn 0 for a millisecond.<br />
<img src="http://blog.openttdcoop.org/files/pictures/logic_gates/not_gate.png" width="400" height="213" alt="The NOT-Gate" title="The NOT-Gate" /></p>
<h3>The OR-Gate</h3>
<p>The OR-Gate was the trickiest to construct. I had many problems with incorrect output in the beginning, but I found a clever solution. Again you need a loop and a one-tile prio for the input x. If input x turns red, the first train will stop at the entry-signal of the inner loop right in front of input x. The second train will avoid the inner loop and use the outer loop. If the train is there, the output turns red regardless of the input y. The thing I am really proud of is, if input y turns red, the loop is ignored and the output turns red immediately.<br />
<img src="http://blog.openttdcoop.org/files/pictures/logic_gates/or_gate.png" width="400" height="213" alt="The OR-Gate" title="The OR-Gate" /></p>
<h3>More Logic Gates</h3>
<p>With these three logic gates you can create many other logic gates or logical constructions such as XOR, half adders, full adders or even flipflops. Though I doubt it is possible to create a complete <a href="http://en.wikipedia.org/wiki/Arithmetic_Logic_Unit" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Arithmetic_Logic_Unit?referer=');">ALU</a> (e.g. the slow reaction time), but constructions helping us to regulate the traffic and the movement of our trains in complex openttdcoop network should be possible.<br />
<a class="image-link" href="http://blog.openttdcoop.org/files/pictures/logic_gates/xor_example.png"><img class="left" src="http://blog.openttdcoop.org/files/pictures/logic_gates/thumb_xor_example.png" width="346" height="178" alt="XOR-Gate by Osai" title="XOR-Gate by Osai"  /></a><br />
<br class="clear" /></p>
<p>I hope you gain something from my little article about logic gates and enjoyed reading. Now head on, build your own logic gates or implement them in any other weird network construction. Please post your results as comments, at our <a href="http://www.openttdcoop.org/wiki/" onclick="pageTracker._trackPageview('/outgoing/www.openttdcoop.org/wiki/?referer=');">wiki</a> or send an email to info [at] openttdcoop [dot] org.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.openttdcoop.org/2008/06/17/the-insane-led-counter-logic-gates-part-1/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
