This commit is contained in:
Guillaume BONABAU 2024-05-29 12:25:00 +02:00
commit 62567131e3
2 changed files with 22 additions and 14 deletions

View File

@ -5,8 +5,6 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
//import for json
import org.json.simple.JSONArray;
@ -226,30 +224,28 @@ public class Simulator extends Thread {
if (agents.get(i).getX() == x && agents.get(i).getY() == y ){
agents.remove(i);
System.out.println("Corresponding agent found, proceeding with removal");
System.out.println(agents.size());
removal = true;
}
}
if(i==agents.size() && removal ==false){
//if we find no corresponding agent after the for loop, we add one
System.out.println("no agents to remove, proceeding with creation");
setSheep(x, y);
if (enableLogs) {
System.out.println("clickAgent Called, Agent created at: " + x + "," + y + "");
}
}
}
else{
System.out.println("1st iteration");
setSheep(x,y);
}
if (enableLogs) {
System.out.println("clickAgent Called, Agent created at: " + x + "," + y + "");
}
}
}
}
//TODO-INPROGRESS : set agent (x y agent) load an agent to coordinates x,y
@ -589,6 +585,12 @@ public class Simulator extends Thread {
}
//debug print the list of rules
public void printRules(ArrayList<Rule> ruleArrayList) {
System.out.println("-----------------------------------");
@ -605,6 +607,4 @@ public class Simulator extends Thread {
}
}
}

View File

@ -17,6 +17,7 @@ public class JPanelDraw extends JPanel {
private Simulator mySimu;
private MyInterface interfaceGlobal;
ArrayList<ArrayList<Integer>> colorArrayList;
ArrayList<ArrayList<Integer>> colorArrayList;
public JPanelDraw(MyInterface itf) {
super();
@ -71,6 +72,13 @@ public class JPanelDraw extends JPanel {
} else {
g.setColor(Color.white);
}
if(cellContent == 2) {
g.setColor(Color.yellow); //set collor with rgb value (255,255,0)
//g.setColor(new Color(255,255,0));
}
if(cellContent == 3) {
g.setColor(Color.red);
}
g.fillRect(
(int) Math.round(x*cellWidth),
(int) Math.round(y*cellHeight),