Help on improving my bot

void loop()
{
sensor(b);
delay(100);
a=sensor(b);
delay(100);
motor(a);
delay(100);
}

Well, you were right. It is pathetic.

Start with some names that follow the Arduino (and every other intelligent programming paradigm) convention of function names that consist of a noun and a verb (like digitalRead(), analogWrite(), etc.).

One can only guess at what sensor() is supposed to do. Clearly, calling it with and without storing the return value is contradictory. If the function returns a value, discarding it is silly.

The robot() will do NOTHING during the stickYourThumbUpYourAssAndDoNothing() (aka delay()) call.

int sensor(int b)
{ delay(50);                    
  unsigned int uS = sonar.ping(); 
  b = (uS / US_ROUNDTRIP_CM);
  return b;
}

Assigning a value to the input argument does not make sense.

int motor(int a)
{
 int val=a;
  if(val==0 || val>20)
   GoForward();

Copying the input value, and then ignoring the input value, while never changing the copy, does not make sense.

Posting code that is so poorly indented does not make sense. Especially when Tools + Auto Format is so easy to use.

While I'm at it, zipping a single ino file, whose size is well under the cut-and-paste in a code box limit, and attaching it does not make sense.