import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.core.Runtime;
import jade.wrapper.AgentContainer;

/**
 * Program 1: Provider + Searcher demo
 *
 * Starts P1-P6 with different service combinations, then launches
 * Searcher agents S1, S2, S3 to query the DF for each service.
 */
public class Run1 {
    public static void main(String[] args) throws Exception {

        Runtime rt = Runtime.instance();
        rt.setCloseVM(true);

        ProfileImpl mainProf = new ProfileImpl();
        mainProf.setParameter(Profile.GUI, "true");
        AgentContainer mainC = rt.createMainContainer(mainProf);

        mainC.createNewAgent("P1", "agents.Provider", new Object[]{"1","0","0"}).start(); // Service1 only
        mainC.createNewAgent("P2", "agents.Provider", new Object[]{"0","1","0"}).start(); // Service2 only
        mainC.createNewAgent("P3", "agents.Provider", new Object[]{"0","0","1"}).start(); // Service3 only
        mainC.createNewAgent("P4", "agents.Provider", new Object[]{"1","1","0"}).start(); // Service1 + Service2
        mainC.createNewAgent("P5", "agents.Provider", new Object[]{"0","1","1"}).start(); // Service2 + Service3
        mainC.createNewAgent("P6", "agents.Provider", new Object[]{"1","1","1"}).start(); // all three

        Thread.sleep(30000);

        mainC.createNewAgent("S1", "agents.Searcher", new Object[]{"Service1"}).start();
        mainC.createNewAgent("S2", "agents.Searcher", new Object[]{"Service2"}).start();
        mainC.createNewAgent("S3", "agents.Searcher", new Object[]{"Service3"}).start();
    }
}
