<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.zenerves.net/skins/common/feed.css?301"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
		<id>http://wiki.zenerves.net/index.php?action=history&amp;feed=atom&amp;title=Drunken_tribot_v3</id>
		<title>Drunken tribot v3 - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.zenerves.net/index.php?action=history&amp;feed=atom&amp;title=Drunken_tribot_v3"/>
		<link rel="alternate" type="text/html" href="http://wiki.zenerves.net/index.php?title=Drunken_tribot_v3&amp;action=history"/>
		<updated>2026-08-01T12:27:15Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.17.0</generator>

	<entry>
		<id>http://wiki.zenerves.net/index.php?title=Drunken_tribot_v3&amp;diff=38&amp;oldid=prev</id>
		<title>Admin: 1 revision</title>
		<link rel="alternate" type="text/html" href="http://wiki.zenerves.net/index.php?title=Drunken_tribot_v3&amp;diff=38&amp;oldid=prev"/>
				<updated>2011-10-14T20:49:22Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 20:49, 14 October 2011&lt;/td&gt;
		&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://wiki.zenerves.net/index.php?title=Drunken_tribot_v3&amp;diff=37&amp;oldid=prev</id>
		<title>Lola: Protected &quot;Drunken tribot v3&quot; [edit=autoconfirmed:move=autoconfirmed]</title>
		<link rel="alternate" type="text/html" href="http://wiki.zenerves.net/index.php?title=Drunken_tribot_v3&amp;diff=37&amp;oldid=prev"/>
				<updated>2011-04-10T15:47:00Z</updated>
		
		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/index.php?title=Drunken_tribot_v3&quot; title=&quot;Drunken tribot v3&quot;&gt;Drunken tribot v3&lt;/a&gt;&amp;quot; [edit=autoconfirmed:move=autoconfirmed]&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; /*                       learning NXC with Lola&lt;br /&gt;
 &lt;br /&gt;
                    THE MARCH OF THE DRUNKEN TRIBOT v3                    &lt;br /&gt;
  &lt;br /&gt;
         Simple escape-the-room by bumper programme with Random Moves.&lt;br /&gt;
                 And Tridiot hates Green Tiles too, makes him puke!                   */ &lt;br /&gt;
  &lt;br /&gt;
 mutex moveMutex;                      // start of code &lt;br /&gt;
 &lt;br /&gt;
 // Case 1: Poking Around &lt;br /&gt;
 // Tridiot tries to move forward. That ain't an easy task.&lt;br /&gt;
 task poke()&lt;br /&gt;
 {&lt;br /&gt;
   while (true)                        // Don't Ask; remove it &amp;amp; it won't compile&lt;br /&gt;
   {&lt;br /&gt;
     Acquire(moveMutex);               // Grab Control over the engines&lt;br /&gt;
     do                                // do the following until... something happens!&lt;br /&gt;
     {&lt;br /&gt;
       OnFwd(OUT_AC, 50);              // Forward 50%&lt;br /&gt;
       Wait(Random(1000)+500);         // For a random amount of time + 500 (gives a minimal value)&lt;br /&gt;
       OnRev(OUT_A, Random(90));       // turn away by reversing engine A random between 0 &amp;amp; 90&lt;br /&gt;
       OnRev(OUT_C, Random(90));       // Turn away by reversing motor C at a differennt value&lt;br /&gt;
       Wait(Random(400+200));          // On a random timeframe too.&lt;br /&gt;
     }&lt;br /&gt;
     while (SENSOR_1 == 0);            // This one is not supposed to be neccessary.&lt;br /&gt;
     Release(moveMutex);               // Give &amp;quot;back&amp;quot; the motors to the other snippets&lt;br /&gt;
   }&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 // Case 2: the Puke&lt;br /&gt;
 // That's when Tridiot steps over a green tile in my office, the color makes him puke... &lt;br /&gt;
 task puke()                           // LightSensor (port 3) activated&lt;br /&gt;
 {&lt;br /&gt;
   while (true)&lt;br /&gt;
   {&lt;br /&gt;
     Acquire(moveMutex);               // Grab Control over the engines&lt;br /&gt;
     if (Sensor(IN_3) &amp;gt; 27)            // YOU PROBABLY WILL HAVE TO EDIT THIS ONE&lt;br /&gt;
     {&lt;br /&gt;
       OnRev(OUT_C, 45);               // Back up Motor_C&lt;br /&gt;
       Wait(400);                      // (briefly)&lt;br /&gt;
       until(Sensor(IN_3) &amp;lt;= 30);      // Check sensor: Am I away of this most horrible colour?&lt;br /&gt;
       OnFwd(OUT_AC, 35);              // If so, move on! Pfew, I though I was going to be sick!&lt;br /&gt;
     }&lt;br /&gt;
     Release(moveMutex);               // Give &amp;quot;back&amp;quot; the motors to the other snippets&lt;br /&gt;
   }&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 // Case 3: the Crash &lt;br /&gt;
 // Tridiot bumps into something, Aargh, sorry sir, and decides to move away. or so he tries.&lt;br /&gt;
 task crash()                          // Touch Sensor (port 1) activated&lt;br /&gt;
 {&lt;br /&gt;
   while (true)                        // Don't Ask; remove it &amp;amp; it won't compile&lt;br /&gt;
   {&lt;br /&gt;
     Acquire(moveMutex);               // Grab Control over the engines&lt;br /&gt;
     if (SENSOR_1 == 1);               // When CRAAAASH&lt;br /&gt;
     OnRev(OUT_AC, 75);                // Back off, you thingy...&lt;br /&gt;
     Wait(750);                        // for the amount of time and speed as defined&lt;br /&gt;
     if (Random() &amp;gt;= 0)                // IF statement, what happens if... the value is BELOW Zero:&lt;br /&gt;
     {&lt;br /&gt;
       OnRev(OUT_C, Random(50)+50);    // Motor C backs off, at least 50% + random of 50 remaining&lt;br /&gt;
     }&lt;br /&gt;
     else                              // ELSE statement: returned value is ABOVE zero.&lt;br /&gt;
     {&lt;br /&gt;
       OnRev(OUT_A, Random(50)+50);    // Motor A backs off, at least 50% + random of 50 remaining&lt;br /&gt;
     }&lt;br /&gt;
     Wait(Random(600)+400);            // Even the duration of the re-direction is random.&lt;br /&gt;
     Release(moveMutex);               // Give &amp;quot;back&amp;quot; the motors to the other snippets&lt;br /&gt;
   }&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 //totally superfluous &amp;quot;humming&amp;quot; thread&lt;br /&gt;
 //should be re-worked in a hiccup noise, that would fit!&lt;br /&gt;
 #define TIME 200&lt;br /&gt;
 #define MAXVOL 7&lt;br /&gt;
 #define MIDVOL 3&lt;br /&gt;
 #define pause_4th Wait(TIME)&lt;br /&gt;
 #define pause_8th Wait(TIME/2)&lt;br /&gt;
 #define note_4th \&lt;br /&gt;
   PlayFileEx(&amp;quot;! Click.rso&amp;quot;,MIDVOL,FALSE); pause_4th&lt;br /&gt;
 #define note_8th \&lt;br /&gt;
   PlayFileEx(&amp;quot;! Click.rso&amp;quot;,MAXVOL,FALSE); pause_8th&lt;br /&gt;
 &lt;br /&gt;
 task hum()&lt;br /&gt;
 {&lt;br /&gt;
   while (true)&lt;br /&gt;
   {&lt;br /&gt;
   Wait(2000);&lt;br /&gt;
   note_4th;&lt;br /&gt;
   note_8th;&lt;br /&gt;
   note_8th;&lt;br /&gt;
   note_4th;&lt;br /&gt;
   note_4th;&lt;br /&gt;
   pause_4th;&lt;br /&gt;
   note_4th;&lt;br /&gt;
   note_4th;&lt;br /&gt;
   Wait(100);&lt;br /&gt;
   }&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 // Actual Starting &amp;quot;mother&amp;quot; thread: lauches the others.&lt;br /&gt;
 task main()&lt;br /&gt;
 {&lt;br /&gt;
   Precedes(poke, puke, crash, hum);   // These are the threads to launch&lt;br /&gt;
   SetSensorTouch(IN_1);               // These are the Sensors we'll use:&lt;br /&gt;
   SetSensorLight(IN_3);               // Touch for &amp;quot;Crash&amp;quot; and Light for &amp;quot;Puke&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // EoC. Eurgh.&lt;br /&gt;
&lt;br /&gt;
[[User:Lola|Lola]] 15:43, 1 July 2008 (UTC)&lt;br /&gt;
&lt;br /&gt;
[[Category:Snippets]]&lt;/div&gt;</summary>
		<author><name>Lola</name></author>	</entry>

	</feed>