Simulator program for a robot designed to move packages around in a warehouse

This is a discussion on Simulator program for a robot designed to move packages around in a warehouse within the C Programming forums, part of the General Programming Boards category; I need advice on how to start this programming project. Any advice/help will be very appriciated as it is due ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    3

    Simulator program for a robot designed to move packages around in a warehouse

    I need advice on how to start this programming project. Any advice/help will be very appriciated as it is due very soon and unfortunately programming is not one of my strongest points.

    The task for the project is to write a simulator program for a robot designed to move packages around in a warehouse environment.

    The input to the program (from standard input) will contain a map of the environment in its original state, together with a sequence of instructions to be performed by the robot.

    The map specifies the size (40 by 80 max), 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 whether it is facing up, down, left or right. There will be at most 26 "packages" in the environment, labeled with the letters A,B, etc. (packages may vary in size and shape).


    Robot control commands

    The robot is capable of four basic operations, as follows:

    L turn left
    R turn right
    F (try to) move forward
    P print the state of the environment


    The instructions for the robot will consist of an ordered sequence of these four basic instructions L,R,F,P, enclosed in parentheses.

    eg:
    (FFFFFRFFFLFRFFFFRFFPLFFFRFRFFFFFFFFFFFFFP)

    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 pointing.

    If there is a package immediately in front of the robot when it tries to move forward, the package will move with the robot (in the same direction). If there are one or more packages immediately in front of that package, they will also move, as well the packages immediately in front of them, etc. We assume the robot is strong enough to push any number of packages in front of it. Since the walls are immovable, however, there will be some situations where the robot tries to move forward but fails. This will happen if there is a wall immediately in front of the robot, or if there is a wall immediately in front of a package being pushed by the robot (either directly or indirectly). In these cases, the F instruction has no effect on the environment, and the robot continues to the next instruction. (Part of the challenge of the project is to determine which packages are being pushed, and whether or not a wall is being pushed.)

    The robot leaves a trail behind it wherever it goes. So, when the environment is printed, places where there is no package or wall should be indicated by a dot '.' if the robot has been there at some time during its path, and a blank space ' ' otherwise.

    Cheers,
    Denise

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Do you have anything done on this? This is a pretty big program to just expect someone to do.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    3
    I tried to put the map in to a 2-D array and the Instruction into another 1-D array. I'm stucj when it comes to moving the robot round. I'm not sure how to get the robot position integrated into teh follow_instructions function.

    This is what I've done so far:

    #include <stdio.h>

    #define NROWS 40
    #define NCOLS 80
    #define INSTRUC 20

    typedef char Map;
    typedef char Instruction;

    void get_map(Map map[][NCOLS], int nrows);
    void get_instruction(Instruction instruction[],int instruc);
    void follow_instruction(Instruction instruction[], Map map[]);


    int main ( void )
    /***************/
    {

    Map map[NROWS][NCOLS];
    Instruction instruction[INSTRUC];

    get_map(map, NROWS);
    get_instruction(instruction, INSTRUC);
    follow_instruction(instruction, map);


    return 0;
    }

    void get_map(Map map [][NCOLS], int nrows)
    /****************************************/
    {

    int row, col;
    for (row = 0; row < nrows && scanf("%d", map[][] != "(" ); row++)
    for (col = 0; col < NCOLS; col++)
    scanf("%d", map[row][col]);
    }

    return;
    }

    void get_instruction(Instruction instruction[INSTRUC], int instruc)
    /************************************************** **********/
    {

    int i;

    for (i = 0; i < instruc && scanf("%d", instruction[]) != ")"; i++)

    return ;
    }

    void follow_instruction(Instruction instruction[INSTRUC}, Map map[][])
    /************************************************** ******************/
    {

    while( c = getchar(instruction[]))
    if (c = getchar(instruction[] == F && map has ^ (??????))
    map[row--][]
    if

    etc....
    return;
    }

  4. #4
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    I'd get the input for the map from the user. Unfortunately it's not a file, but anyway, I'd turn it into a binary file and use random access to manipulate and read it based on the robots instructions. You could than delete the binary file. Consider it a temporary file.
    I compile code with:
    Visual Studio.NET beta2

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    35
    this must be the weirdest post i have ever read!

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    This
    - reads a map / initial robot position from a file
    - follows a sequence of instructions

    At present the robot just tramples over boxes

    > packages may vary in size and shape
    Detecting whether a box (or stack of boxes) is movable is the interesting part. If they're always rectangular, in a rectangular map, it will be easier. Odd shaped boxes in an odd shaped map will be harder.
    Attached Files Attached Files
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help! Robot Programming
    By Gizzle in forum C Programming
    Replies: 23
    Last Post: 09-28-2006, 07:32 AM
  2. Help with moving robot in a maze
    By Killahkode in forum C Programming
    Replies: 2
    Last Post: 09-25-2006, 10:51 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  4. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 06:18 AM
  5. Formatting Output
    By Aakash Datt in forum C++ Programming
    Replies: 2
    Last Post: 05-16-2003, 08:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21