From 5575017ee446c4ca10cac8309b8f018d44835964 Mon Sep 17 00:00:00 2001
From: Balthazar Wilson <balthazar.wilson@etu.utc.fr>
Date: Tue, 26 Dec 2023 12:17:33 +0100
Subject: [PATCH] infinite simu with -1 maxstep

---
 simu/simu.go | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/simu/simu.go b/simu/simu.go
index d8d4491..2d0befa 100644
--- a/simu/simu.go
+++ b/simu/simu.go
@@ -227,12 +227,22 @@ func (simu *Simulation) Run() {
 	for _, agent := range simu.Agents {
 		go func(agent agt.Agent) {
 			step := 0
-			for step < simu.maxStep {
-				step++
-				c, _ := simu.syncChans.Load(agent.ID())
-				c.(chan int) <- step
-				time.Sleep(500 * time.Millisecond)
-				<-c.(chan int)
+			if simu.maxStep < 0 {
+				for {
+					step++
+					c, _ := simu.syncChans.Load(agent.ID())
+					c.(chan int) <- step
+					time.Sleep(500 * time.Millisecond)
+					<-c.(chan int)
+				}
+			} else {
+				for step < simu.maxStep {
+					step++
+					c, _ := simu.syncChans.Load(agent.ID())
+					c.(chan int) <- step
+					time.Sleep(500 * time.Millisecond)
+					<-c.(chan int)
+				}
 			}
 		}(agent)
 	}
-- 
GitLab