Simple flooding

Simple flooding preview image

1 collaborator

Default-person Abdellah Madani (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 549 times • Downloaded 37 times • Run 0 times
Download the 'Simple flooding' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;A. Madani
;Simulation de la diffusion aveugle : simple flooding or blind flooding;
turtles-own
[
  nbre-copies? ;indique le nombre de copies d'un message reçu par un noeud
]

to setup
  ca
  crt density ;créer plusieurs noeuds, le premier noeud doit initier l'envoi des messages
  ask turtles [
    set xcor random-xcor * 0.98
    set ycor random-ycor * 0.98
    set shape "circle"
    set color green 
    set nbre-copies? 0
    set label nbre-copies?
    ]
  ask turtle 0 [
    set nbre-copies? 1
    set label nbre-copies?
    set color red
  ]  
  creer-liens ;créer des liens entre les noeuds  
end 

;créer des liens entre les noeuds en se basant sur le rayon de couverture : R

to creer-liens
  ask turtles[
    let i 0
    let ch (other turtles with [distance myself < R])
    create-links-with ch
  ]                
ergonomie
end 

to broadcast
  ask-concurrent turtles with [nbre-copies? = 1] [
    ask link-neighbors  [
      a-recu
      set label nbre-copies?
    ]
  ]
end 

to go
  ;on quite si tous les noeuds ont été atteints, ou au moins un noeud a reçu plus que 100 copies
  if all? turtles [nbre-copies? != 0]
  [ stop ]
  if any? turtles with [nbre-copies? > 100]
  [ stop ]  
  broadcast
  clear-links
  ;;je crois que le déplacement est inutile puisqu'on a utilisé "ergonomie"
  ;ask turtles [
    ;fd 1
  ;]  
  creer-liens    
  dessine-graphes  
  ergonomie  
end 

to a-recu
  set nbre-copies? (nbre-copies? + 1) 
  set color red
end 

to ergonomie
   repeat 10
  [
    layout-spring turtles links 0.3 (world-width /(sqrt density)) 1
  ]
end 

to dessine-graphes                            
  set-current-plot "graphe"                 
  set-current-plot-pen "pen1"            
  plot count turtles with [color = red]                      
end 

There is only one version of this model, created over 6 years ago by Abdellah Madani.

Attached files

File Type Description Last updated
Simple flooding.png preview Preview for 'Simple flooding' over 6 years ago, by Abdellah Madani Download

This model does not have any ancestors.

This model does not have any descendants.