From d591e83bca40ac29fc04f4528a773a0b118d2225 Mon Sep 17 00:00:00 2001 From: g le-chartier Date: Wed, 29 May 2024 11:38:13 +0200 Subject: [PATCH] optimized code for agents --- src/backend/Simulator.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 4b537df..c96f167 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -225,29 +225,27 @@ 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"); - + else{ setSheep(x,y); + if (enableLogs) { + System.out.println("clickAgent Called, Agent created at: " + x + "," + y + ""); + } } - if (enableLogs) { - System.out.println("clickAgent Called, Agent created at: " + x + "," + y + ""); - } + } }