Obstacle avoidance with an UGV -HELP PLEASE-

Haha thanks! I'm looking to improve the algorithm for obstacle avoidance, but I'm not sure how to do it. Instead of listing a million if statements, I wasn't sure if I could accomplish this with a few for or while loops. Can it be done?