public Point toGate(Point current){
		double ox = 0, oy = 0;
		Point gate = new Point(dimension/2, dimension/2);
		// if both the x and y of the piper are farther than 1 from the gate, change both
		// !finishround signifies that the piper is not ready to move towards the target yet
		if(Math.abs(gate.x - current.x) > 1 && Math.abs(gate.y - current.y) > 1 && !finishround){
			double dist = PlayUtilities.distance(current, gate);
			assert dist > 0;
			
			ox = (gate.x - current.x) / dist * mpspeed;
			oy = (gate.y - current.y) / dist * mpspeed;
		}
		// if the x of the piper is farther than 1 from the gate, change x
		else if(Math.abs(gate.x - current.x) > 1  && !finishround){
			double dist = PlayUtilities.distance(current, gate);
			assert dist > 0;
			
			ox = (gate.x - current.x) / dist * mpspeed;
		}
		// if the y of the piper is farther than 1 from the gate, change y
		else if(Math.abs(gate.y - current.y) > 1  && !finishround){
			double dist = PlayUtilities.distance(current, gate);
			assert dist > 0;
			
			oy = (gate.y - current.y) / dist * mpspeed;
		}
		// now the piper is close to the gate, so it can move towards the target
		else if(Math.abs(target.x - current.x) > 1){
			finishround = true; // change finishround to false to show that the piper has finished sweeping its region and can move to the left side
			double dist = PlayUtilities.distance(current, target);
			assert dist > 0;
			
			ox = (target.x - current.x) / dist * mpspeed;
		}
		
		Point next = new Point(current.x + ox, current.y + oy);
		return next;
			
	}