import becker.robots.*;
import java.util.Random;

public class A2_Part_3 extends Object
{
    public static void main(String[] args)
    {   
        City wallville = new City(6, 12);
        Robot rob = new Robot(wallville, 1, 2, Direction.EAST, 0);
        
        A2_Part_3.BuildCity(wallville); // this jumps down to the "BuildCity" routine, below

        // * * * Your code to race around the race track goes here:  * * *
        
    }
    
    public static void BuildCity(City wallville)
    {
        // Width and height must be at least 2 (each)
        // Feel free to change these numbers, and see how your racetrack changes
		
		Random r = new Random();
		int top = 1;
		int left = 2;
		int height = 4;
		int width = 7 + r.nextInt(4);
		
        int streetNumber = top;
        while(streetNumber <= height)
        {
			if(streetNumber == 1)
            {
				// the topmost line:
				new Wall(wallville, streetNumber, left, Direction.NORTH);
			}
			else if ( streetNumber == height )
            {
				// generate the 'holding spot' thing at the bottom:
				
				// the corner:
				new Wall(wallville, streetNumber+1, left, Direction.WEST);
				new Wall(wallville, streetNumber+1, left, Direction.SOUTH);
				int spotNum = left + 1;
				int counter = 0;
				while(counter < height)
				{
					new Wall(wallville, streetNumber+1, spotNum, Direction.NORTH);
					new Wall(wallville, streetNumber+1, spotNum, Direction.SOUTH);
					// Uncomment the next line for a 'final state' picture (i.e., the second picture
					// in the assignment)
					// new Thing(wallville, streetNumber+1, spotNum);
					spotNum = spotNum + 1;
					counter = counter + 1;
				}
				new Wall(wallville, streetNumber+1, spotNum, Direction.WEST);
			}
			
			// the west-most, vertical line:
			new Wall(wallville, streetNumber, left, Direction.WEST);
			// the east-most, vertical line:
			new Wall(wallville, streetNumber, width, Direction.EAST);
			// the Thing at the end of the tunnel
			new Thing(wallville, streetNumber, width);

			int aveNum = left+1;
			while(aveNum <= width)
			{
				new Wall(wallville, streetNumber, aveNum, Direction.NORTH);
				new Wall(wallville, streetNumber, aveNum, Direction.SOUTH);
				aveNum = aveNum + 1;
			}
            
            streetNumber = streetNumber + 1;
        }		
    }        
}
