int LightThreshold ; int Speed ; sub findLineSpiral() { int ratio = 30; while ((SENSOR_3 >= LightThreshold)) { OnFwdSync(OUT_BC, Speed, ratio); Wait(200); if ((ratio > 20)) { ratio -= 1; } } } sub findLine() { int __temp18 = 0; int tvar = __temp18; int lineFound = __temp18; int turnLeft = __temp18; if ((Random(2) > 0)) { turnLeft = 1; } long longTimeout = 10; long longStartTime = 0; while (!(lineFound)) { longStartTime = CurrentTick(); tvar = 100; if (turnLeft) { tvar *= -1; } OnFwdSync(OUT_BC, Speed, tvar); while (( ( CurrentTick() - longStartTime ) < longTimeout) || lineFound) { if ((SENSOR_3 < LightThreshold)) { lineFound = 1; } } if (!(lineFound)) { turnLeft = !(turnLeft); if ((longTimeout > 1000)) { findLineSpiral(); lineFound = 1; } else { longTimeout += 100; } } } } task main() { int __temp49 = 50; LightThreshold = __temp49; Speed = __temp49; SetSensorLight(IN_3); findLineSpiral(); OnFwd(OUT_BC, Speed); while (true) { if ((SENSOR_3 > LightThreshold)) { findLine(); OnFwd(OUT_BC, Speed); } } }