Hey, im doing my first programming subject and i really need help with an assignment.

I have to write a simulator program for a robot designed to move packages around in a warehouse environment.

The map specifies the size, shape and initial positions of all the packages in the environment, as well as the positions of the walls, and the initial position and orientation of the robot. The walls will be represented by the "star" character *. The robot will be represented by the characters ^, v, < or >, depending on which direction it is facing.

I can only give the robot 4 commands:
L turn left
R turn right
F (try to) move forward
P print the state of the environment

When it executes an L or R instruction, the robot remains in the same location and only its orientation changes. When it executes the F instruction, the robot attempts to move a single step in whichever direction it is facing.


Right now i can get the robot to scan the environment and print out what it sees. But i can't get my robot to move.. can anyone give me any pointers??

heres the code i have so far.

Code:
#include <stdio.h>

#define ROBOT       26
#define WALL        27
#define NONE        -1

#define MAX_ROWS    80
#define MAX_COLS    80

#define EAST         0
#define NORTH        1
#define WEST         2
#define SOUTH        3

void scan_state(
                 int *pnrows,
                 int  ncols[MAX_ROWS],
                 int  object[MAX_ROWS][MAX_COLS],
                 int *pdirection
	       );

void print_state(
                 int nrows,
                 int ncols[MAX_ROWS],
                 int object[MAX_ROWS][MAX_COLS],
                 int direction
	        );

int main( void )
{
  int nrows;                      // number of rows in environment
  int ncols[MAX_ROWS];            // number of columns in each row
  int object[MAX_ROWS][MAX_COLS]; // object at each location
  int direction;                  // which way the robot is facing

  // scan the state of the environment
  scan_state( &nrows, ncols, object,&direction );

  // print the state of the environment
  print_state( nrows, ncols, object, direction );

  return 0;
}

void scan_state(
                 int *pnrows,
                 int  ncols[MAX_ROWS],
                 int object[MAX_ROWS][MAX_COLS],
                 int *pdirection
               )
{
  int ch;
  int r,c,rr,rc;

  r = 0;
  c = -1;

  while (( ch = getchar() ) != '(' ) {
    c++;
    if ( ch == '\n' ) {
      ncols[r++] = c;
      c = -1;
    }
    else if ( ch == '*' ) {
      object[r][c] = WALL;
    }
    else if ((ch >='A' )&&( ch <= 'Z')){
       object [r][c]= ch - 'A';  
    }
    else if ( ch == '^' ) {
      object [r][c] = ROBOT;
      *pdirection = NORTH;
    }
    else if ( ch == '>' ) {
      object [r][c] = ROBOT;
      *pdirection = EAST;
    }
    else if ( ch == 'v' ) {
      object [r][c] = ROBOT;
      *pdirection = SOUTH;
    }
    else if ( ch == '<' ) {
      object [r][c] = ROBOT;
      *pdirection = WEST;
    }
    else {
      object [r][c] = NONE;
    }
  }
  
  //give the robot its own cordinates.
  if (object[r][c] == ROBOT ) {
  object[rr][rc] = ROBOT;
  }
  
  while (( ch = getchar() ) != ')' ) {
    c++;
    if ( ch == '\n' ) {
      ncols[r++] = c;
      c = -1;
    }
    else if ( ch == 'L' ) {
      if ( *pdirection == SOUTH ) {
          *pdirection = EAST;
      }
      else {
        *pdirection++;
      }
    }
    else if (ch == 'R' ) {
      if ( *pdirection == EAST ) {
           *pdirection = SOUTH;
      }
      else {
        *pdirection--;
      }
    }
  }

 *pnrows = r;
}


void print_state(
                 int nrows,
                 int ncols[MAX_ROWS],
                 int object[MAX_ROWS][MAX_COLS],
                 int direction
                )
{
int r,c;

for( r=0; r < nrows ; r++ ) {
   for( c=0; c < ncols[r]; c++ ) {
      if (object[r][c] == WALL) {
      printf( "*" );
      }
      if (object[r][c] == NONE) {
      printf( " " );
      }
      if ((object [r][c]>= 0)&&(object [r][c]<= 25)){
         printf("%c",'A'+object [r][c]);
      }

      if ( object[r][c] == ROBOT ) {
        if (direction == NORTH) {
          printf("^");
        }
        if (direction == EAST) {
          printf(">");
        }
        if (direction == SOUTH) {
          printf("v");
        }
        if (direction == WEST) {
          printf("<");
        }
      }

   }
   printf( "\n" );
}


}
Thanks a lot.. i know its a crapload to read but any help is appreciated..

cheers