Created
February 16, 2018 00:44
-
-
Save cipher982/72b7930427f3b2484f5199806e38fa8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (car_ahead) | |
{ | |
cout << "Car Ahead!!!\n\n\n\n\n\n" | |
<< endl; | |
if (!car_left && lane > 0) // no left-car, yes left-lane | |
{ | |
lane--; // Change lane left | |
} | |
else if (!car_right && lane != 2) // no right-car, yes right-lane | |
{ | |
lane++; // Change lane right | |
} | |
else | |
{ | |
speed_diff -= max_acl; // else slow down | |
} | |
} | |
else | |
{ | |
if (lane != 1) // not in center lane | |
{ | |
if ((lane == 0 && !car_right) || (lane == 2 && !car_left)) // left-right is clear | |
{ | |
lane = 1; // Back to center. | |
} | |
} | |
if (ref_vel < max_vel) | |
{ | |
speed_diff += max_acl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment