Skip to content
Snippets Groups Projects
Commit 617eaadc authored by Yousra Hassan's avatar Yousra Hassan
Browse files

implementation usager impoli

parent 9ca5c4dc
No related branches found
No related tags found
1 merge request!14Merge v2
......@@ -9,7 +9,6 @@ package simulation
*/
import (
"fmt"
"log"
"math/rand"
alg "metrosim/internal/algorithms"
......@@ -258,7 +257,6 @@ func (ag *Agent) MoveAgent() bool {
for !accept && i < 3 {
//Demande à l'agent qui bloque de se pousser (réitère trois fois s'il lui dit pas possible)
i += 1
fmt.Printf("Je suis %s, bouge %s iteration %d \n", ag.id, blockingAgentID, i)
reqToBlockingAgent = NewRequest(ag.env.agentsChan[ag.id], YouHaveToMove) //Création "Hello, je suis ag.id, move."
ag.env.agentsChan[blockingAgentID] <- *reqToBlockingAgent //Envoi requête
repFromBlockingAgent = <-ag.env.agentsChan[blockingAgentID] //Attend la réponse
......@@ -405,7 +403,7 @@ func (ag *Agent) listenForRequests() {
for {
if ag.request == nil {
req := <-ag.env.agentsChan[ag.id]
fmt.Println("Request received by UsagerLambda:", req.decision)
//fmt.Println("Request received by UsagerLambda:", req.decision)
ag.request = &req
if req.decision == Disappear {
return
......
......@@ -214,6 +214,7 @@ func (simu *Simulation) Print() {
}
fmt.Println()
}
fmt.Println("\n \n \n")
fmt.Println()
//fmt.Println("============================================================")
//time.Sleep(time.Second / 4) // 60 fps !
......
......@@ -38,7 +38,6 @@ func (ul *UsagerLambda) Deliberate(ag *Agent) {
} else if ul.req.decision == Wait {
ag.decision = Wait
} else if ul.req.decision == YouHaveToMove {
fmt.Printf("Je vais essayer")
movement := ag.MoveAgent()
if movement {
ag.decision = 5
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment