@@ -45,12 +45,24 @@ public KnownMap sendMap(String ag)
}
return listKnownMap.get(indmap);

}

public void AckMap(String ag)
{
//on choisi la bonne map a envoyer
int indmap = listAgentShare.indexOf(ag);
if (indmap != -1)
{
listKnownMap.remove(indmap);
}


}
public void mergeMap(KnownMap map)
{
KnownMap mergedMap = new KnownMap();
mergedMap.setDicoPere(listKnownMap.get(0).getDicoPere());
//on ajoute a la nouvelleMap les noeuds differents
System.out.println("on ajoute a la nouvelleMap les noeuds differents");
for(Map.Entry<String, Node> entry : map.getDicoPere().entrySet())
{
String id1 = entry.getKey();
@@ -62,7 +74,7 @@ public void mergeMap(KnownMap map)


}
//on verifie si dans la liste de fils on n'as pas deux fils identiques
System.out.println("on verifie si dans la liste de fils on n'as pas deux fils identiques");
for(Map.Entry<String, Node> entry : listKnownMap.get(0).getDicoFils().entrySet())
{
String id1 = entry.getKey();
@@ -71,7 +83,7 @@ public void mergeMap(KnownMap map)
Node existFilsIdentique = map.getDicoFils().get(id1);
if (existFilsIdentique != null)
{
// si on a des fils identique on fait en sorte que leurs pere pointe sur le meme objet
System.out.println("si on a des fils identique on fait en sorte que leurs pere pointe sur le meme objet");
ArrayList<Node> listPere = listKnownMap.get(0).getPere(n1);
for(Node p : listPere)
{
@@ -91,7 +103,7 @@ public void mergeMap(KnownMap map)



//on verifie si dans le dico de Fils si des Fils ne sont pas pere
System.out.println("on verifie si dans le dico de Fils si des Fils ne sont pas pere");

boolean needToBreak;
while (true)
@@ -104,16 +116,16 @@ public void mergeMap(KnownMap map)
idfils = entry.getKey();
nodefils = entry.getValue();
Node existPere = mergedMap.getDicoPere().get(idfils);
//si des pere sont aussi des fils qui existe on modifie leurs fils pour que l'objet Node pere soit le meme et un pere
System.out.println("si des pere sont aussi des fils qui existe on modifie leurs fils pour que l'objet Node pere soit le meme et un pere");
if (existPere != null)
{
// //System.out.println("J'ai un pere et un fils !");
// //System.out.println("le fils est : "+nodefils);
// //System.out.println("le pere est : "+existPere);
System.out.println("J'ai un pere et un fils !");
System.out.println("le fils est : "+nodefils);
System.out.println("le pere est : "+existPere);
ArrayList<Node> listPere = mergedMap.getPere(nodefils);
for(Node p : listPere)
{
// //System.out.println(p);
System.out.println(p);
p.switchSonToFather(existPere);
}
needToBreak=true;
@@ -122,26 +134,27 @@ public void mergeMap(KnownMap map)


}
// //System.out.println("DEBUT VERIF FILS");
// ArrayList<Node> listf = new ArrayList<>(mergedMap.getDicoFils().values());
// for (Node node : listf) {
// //System.out.println(node);
//
// }
System.out.println("DEBUT VERIF FILS");
ArrayList<Node> listf = new ArrayList<>(mergedMap.getDicoFils().values());
for (Node node : listf) {
System.out.println(node);

}
if(needToBreak)
{
mergedMap.getDicoFils().remove(idfils);
}else{
break;
}
}
// //System.out.println("ICI");
System.out.println("ICI");

listKnownMap.remove(0);
listKnownMap.add(0, mergedMap);




}
public void majMap(List<Couple<String,List<Attribute>>> data)
{
@@ -156,20 +169,20 @@ public void majMap(List<Couple<String,List<Attribute>>> data)
String type ="";
if(father)
{
value = 0;
value = 0;
}
List<Attribute> listAttribute = couple.getRight();
for(Attribute a:listAttribute){

switch (a) {

case TREASURE:

value=(int) a.getValue();
type = a.getName();
break;
case DIAMONDS:

value=(int) a.getValue();
type = a.getName();
break;
@@ -13,4 +13,4 @@ public enum Priorite {
this.name = name;
this.value = value;
}
}
}
@@ -26,7 +26,11 @@ public CalculGoalBehaviour(final FosymaAgent agent) {
public void action() {
managerExplo = new ManageExplo(myFosymaAgent.getMyTreasureType());
String myPosition = ((mas.abstractAgent) this.myAgent).getCurrentPosition();

System.out.println("je suis l'agent : "+this.myFosymaAgent.getName());
System.out.println(this.myFosymaAgent.getMyKnowledge().getListKnownMap().get(0));
System.out.println(this.myFosymaAgent.getMyKnowledge().getListKnownMap().get(0).getDicoFils());


if(myPosition != ""){
if (myFosymaAgent.getMyPath().isEmpty() ) {
Node node = myFosymaAgent.getMyKnowledge().getListKnownMap().get(0).getDicoPere().get(myPosition);
@@ -39,7 +43,11 @@ public void action() {
// }
// }
// Explo Gilles et mathias wombo combo
int maxDepth = 5;



int maxDepth = 6;

if(myFosymaAgent.getBackPackFreeSpace() != 0 && this.myFosymaAgent.getMyCapacity()<100)
{
Goal g = new Goal(myFosymaAgent.getName(), null, myFosymaAgent.getMyCapacity(), myFosymaAgent.getMyTreasureType(),node);
@@ -57,7 +65,13 @@ public void action() {
Goal g = myFosymaAgent.getMyGoal();
g.setGoalPath(tmp);
myFosymaAgent.setMyGoal(g);
System.out.println("\n\n ###############JAI FINIT TA SOEUR ################\n\n");
System.out.println("¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶");
System.out.println("¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶");
System.out.println("¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶");
System.out.println("je suis l'agent : "+this.myFosymaAgent.getName());
System.out.println("¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶");
System.out.println("¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶");
System.out.println("¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶");
}

// Explo Mathias
@@ -92,6 +106,7 @@ public void action() {
// }
// }
}
System.out.println(this.myFosymaAgent+" comme chemin objectif "+this.myFosymaAgent.getMyPath());
}
}

@@ -31,10 +31,11 @@ public MultiBehaviour(final FosymaAgent agent){

this.registerTransition("exchangeMap", "calculGoal",4);

this.registerTransition("calculGoal", "exchangeGoal",5);
//this.registerTransition("calculGoal", "exchangeGoal",5);
this.registerTransition("calculGoal", "explore",5);
this.registerTransition("calculGoal", "explore",6);

this.registerTransition("exchangeGoal", "explore", 7);
//this.registerTransition("exchangeGoal", "explore", 7);

this.registerTransition("explore", "observation",-1);
// this.registerTransition("explore", "theEnd",1000000);
@@ -34,13 +34,13 @@ public static void main(String[] args){
//0) Create the real environment and the observed one
// env= new Environment(ENVtype.GRID_T,6,null);
// env= new Environment(ENVtype.DOROGOVTSEV_T,15,null);
env=new Environment("ressources/map2015","ressources/map2015-config");

//env=new Environment("ressources/map2015","ressources/map2015-config");
env = new Environment("ressources/MP", "ressources/MP-config");
//1), create the platform (Main container (DF+AMS) + containers + monitoring agents : RMA and SNIFFER)
rt=emptyPlatform(containerList);

//2) create agents and add them to the platform.
agentList=createAgents(containerList);
agentList=createAgents(containerList,2);

//3) launch agents
startAgents(agentList);
@@ -173,7 +173,7 @@ private static void createMonitoringAgents(ContainerController mc) {
*@param sniff : a ref to the sniffeur agent
*@return the agentList
*/
private static List<AgentController> createAgents(HashMap<String, ContainerController> containerList) {
private static List<AgentController> createAgents(HashMap<String, ContainerController> containerList,int nbAgents) {
System.out.println("Launching agents...");
ContainerController c;
String agentName;
@@ -224,42 +224,23 @@ private static List<AgentController> createAgents(HashMap<String, ContainerContr
//
//
//Agent0 on container0
c = containerList.get("container0");
agentName="Explo1";
try {
Object[] objtab=new Object[]{env};//used to give informations to the agent
AgentController ag=c.createNewAgent(agentName,FosymaAgent.class.getName(),objtab);
agentList.add(ag);
System.out.println(agentName+" launched");

} catch (StaleProxyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

c = containerList.get("container0");
agentName="Explo2";
try {
Object[] objtab=new Object[]{env};//used to give informations to the agent
AgentController ag=c.createNewAgent(agentName,FosymaAgent.class.getName(),objtab);
agentList.add(ag);
System.out.println(agentName+" launched");
} catch (StaleProxyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

c = containerList.get("container0");
agentName="Explo3";
try {
Object[] objtab=new Object[]{env};//used to give informations to the agent
AgentController ag=c.createNewAgent(agentName,FosymaAgent.class.getName(),objtab);
agentList.add(ag);
System.out.println(agentName+" launched");
} catch (StaleProxyException e) {
// TODO Auto-generated catch block
e.printStackTrace();

for(int i = 1;i<=nbAgents;i++)
{
c = containerList.get("container0");
agentName="Explo"+i;
try {
Object[] objtab=new Object[]{env};//used to give informations to the agent
AgentController ag=c.createNewAgent(agentName,FosymaAgent.class.getName(),objtab);
agentList.add(ag);
System.out.println(agentName+" launched");
} catch (StaleProxyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


System.out.println("Agents launched...");
return agentList;