#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0

    Simple Pathfinding Prog


    Hey there devShed!

    I have been given a piece of coursework and before I go wandering off on my own and messing things up I figured I should best start with a forum of experts.

    • The requirements for the program are to have a "Robot" that moves from one location to another read in from a file, on a 20x20 grid.

    • It can only move forward and turn to look in the directions of NORTH, EAST, SOUTH, WEST.

    • There are also landmarks stored in another file, record the ones I pass over

    • Then print out how far the robot moved.


    Upgrades (Not necessary for a pass)
    • Graphics using swing.

    • Being able to rotate in any direction of 360 degrees.

    • Still print out how far the robot moved but now it's not as simple as I'd need to use trig. now.


    I am a big newbie to programming as a whole, only the basic things I have done through uni I know and I would like any input you guys could give me on how best to start this bad boy of an assignment.

    Kind regards,
    Accendo
  2. #2
  3. Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    May 2004
    Location
    Superior, CO, USA
    Posts
    2,418
    Rep Power
    1713
    I gave you some ideas in your crosspost.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0
    Hey there st, ok as you mentioned the other side of this assignment was a class diagram to illustrate; Classes, Attributes and Methods.

    This is the tutor's near to perfect version:


    I have a lot of classes begun based upon this model, however I am stuck at how I would read in the waypoint's to the robot, then how the robot would know which is the next one :'(. How would I work the Landmark/Waypoint with the LandmarkList /WaypointList too :S.

    But here is my Robot class.

    Code:
    public class Robot
    	{
    		int xpos = 0;
    		int ypos = 0;
    		int distance = 0;
    		LandmarkList Lm;
    		
    		
    		public int getDistance()
    		{
    			return distance;
    		}
    		
    		getVisited()
    		{
    			return Lm;
    		}
    		
    		flipLandmark()
    		{
    			
    		}
    		
    		move()
    		{
    			if (xpos < [Next waypoint].getX()){
                                 xpos++;
                            } else if (xpos > [Next waypoint].getX()) {
                                 xpos--;
                            }
    
    		}
    		
    		
    		
    	}
    This is the location's adult class:
    Code:
    public class Location 
    	{
    		public Location(int x, int y)
    		{
    			
    		}
    		
    		
    		public int getX ()
    		{
    			
    		}
    		
    		
    		public int getY ()
    		{
    			
    		}
    	}
    The main thing above is the move method I haven't done the Y-axis yet ofc. but that's because I just can't figure out how to implement the [next waypoint] thing :S. The way they would be read in is through the MAIN class from a file (which I also don't know how to do) but the format is simply x y.

    Please help me put this into a list and figure out how to read through to the next one!

    I have had a month off over the xMas period and I have never done much Java anyway but I know it's great to learn MAJOR THANKS IF YOU CAN HELP AND EVEN JUST FOR READING THIS FAR!!! Please excuse any childish mistakes I have made as far as missing ';' not closing braces or brackets or not know how to import... thanks again!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0
    I posted this reply to St on another forum but brought it here, I edited my last post but not sure how that works with bumping a reply :S.

    Sorry if this is frowned upon but the above edited message is a whole new message than what I posted at 9!

IMN logo majestic logo threadwatch logo seochat tools logo