public void randomGrid() {
	Random rand = new Random();
/*	resetGrid();
	int b = rand.nextInt(dim*dim);
	barrierPositions = new boolean[dim*dim];
	for(int i = 0; i < b; i++) {
	    barrierPositions[rand.nextInt(barrierPositions.length)] = rand.nextBoolean();
	}
	repaint();
*/
	resetGrid();
	nodeMap = new Node[dim*dim];
	for(int i = 0; i < dim*dim; i++){
		barrierPositions[i] = true;
		nodeMap[i] = new Node(i);
	}
	Node root = new Node(rand.nextInt(dim*dim));
	barrierPositions[root.getIndex()] = false;
	setStart(root.getIndex());
	ArrayList<Node> list = new ArrayList<Node>();
	list = addWalls(root, list);
	while(!list.isEmpty()){
		Node cur = list.remove((int)(Math.random()*list.size()));
		Node opposite = getOpposite(cur);
		if(opposite != null){
			if(barrierPositions[cur.getIndex()] && barrierPositions[opposite.getIndex()]){
				barrierPositions[cur.getIndex()] = false;
				barrierPositions[cur.getParent().getIndex()] = false;
				barrierPositions[opposite.getIndex()] = false;
				list = addWalls(opposite, list);
			}
		}
		if(list.isEmpty()){
			if(!barrierPositions[opposite.getIndex()]){
				setGoal(opposite.getIndex());
			} else {
				GridModel grid = new GridModel(this);
				grid.needToPlaceGoal();
			}
		}		
	}
	repaint();
    }