public Point move(Point[] pipers, // positions of dogs
			Point[] rats) { // positions of the rats
			
		npipers = pipers.length;
		System.out.println(initi);
		Point gate = new Point(dimension/2, dimension/2);
		
		if (!initi) {
			this.init();initi = true;
		}
		Point current = pipers[id]; // Where the pipers are right now
		double ox = 0, oy = 0; // direction of the piper
		//nrats = rats.length;
		
		
		if (getSide(current) == 0 && !sweep) { // if on the left side - starting point
			this.music = false;
			
			// this is the change in movement towards the gate
			double dist = distance(current, gate);
			assert dist > 0;
			ox = (gate.x - current.x) / dist * pspeed;
			oy = (gate.y - current.y) / dist * pspeed;
			System.out.println("move toward the right side");
		}
		else if (!closetoWall(current) && !sweep) { // on the right side and hasn't bounced back yet
			// this is the change in movement based on the angle
			this.music = false;
			ox = pspeed * Math.sin(thetas[id] * Math.PI / 180);
			oy = pspeed * Math.cos(thetas[id] * Math.PI / 180);
		}		
		else { // after bounced and turns on music;
			this.music = true; // music turns on once pipers have reached close to wall
			if(!this.sweep){
				this.sweep = true; // sweeping begins once the pipers have reached close to wall
				assignRats(rats);
			}
			
			ArrayList<Integer> missingRatsIDs = ratsToCollect(pipers, rats); // rats that have to get collected
			System.out.println("number of missing rats = " + missingRatsIDs.size());
			if(missingRatsIDs.size() > 0){
				/*
				String print = "rats to collect are: ";
				for(int i = 0; i < missingRats.size(); i++)
					print += missingRats.get(i) + ", ";
				System.out.println(print);
				*/
				
				System.out.println("hasResponsibility for id=" + id + ":" + hasResponsibility(assignedRats.get(id), missingRatsIDs));
				if(hasResponsibility(assignedRats.get(id), missingRatsIDs)){
					current = toRat(current, missingRatsIDs, rats);	
				}
				else
					current = toGate(current);
				
			}
			else
				current = toGate(current);
				
		}
		
		current.x += ox;
		current.y += oy;
		return current;
	}