Radial path

Radial path preview image

1 collaborator

Default-person Thomas Bronner (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 91 times • Downloaded 8 times • Run 0 times
Download the 'Radial path' 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

breed [lefties lefty]
breed [righties righty]
breed [centers center]
globals[centerx centery sigma]
turtles-own[nom xrel yrel moves_since_fork must_fork_left must_fork_right ]

;left path shifts x+0 and y+1 and forks to right every 4 steps
;right path shifts x+1 and y+1 and forks to left every 3 steps
;center path is 2 rows shifting x+1 and y+2 and forks to left and right every 2 steps
;the first center item is different : forks both left and right on the first step

to setup
  clear-all
  resize-world 0 100 0 70
  set-patch-size 10
  set sigma 1
  set centerx 2
  set centery 1
  create-lefties 1
  ask lefty 0 [
    set nom "L1"
    set xrel 0
    set yrel 1
    set color blue
    set xcor centerx + 0
    set ycor centery + 1
    set must_fork_left false
    set must_fork_right true
  ]
  create-righties 1
  ask righty 1 [
    set nom "R1"
    set xrel 1
    set yrel 1
    set color orange
    set xcor centerx + 1
    set ycor centery + 1
    set must_fork_left true
    set must_fork_right false
  ]
  create-centers 1
  ask center 2 [
    set nom "C1"
    set xrel 1
    set yrel 2
    set moves_since_fork 1 ;;first step is different
    set color green
    set xcor centerx + 1
    set ycor centery + 2
    set must_fork_left true
    set must_fork_right true
  ]
  create-centers 1
  ask center 3 [
    set nom "C2"
    set xrel 1
    set yrel 2
    set xcor centerx + 1
    set ycor centery + 3
    set color 125
    set must_fork_left true
    set must_fork_right false
  ]
  create-centers 1
  ask center 4 [
    set nom "C3"
    set xrel 1
    set yrel 2
    set xcor centerx + 2
    set ycor centery + 3
    set color 115
    set must_fork_left false
    set must_fork_right true
  ]
  reset-ticks
end 

to go
  test
  tick
end 

to test
  ;;coloriage de la case ou l'agent passe
  ask turtles [
    let c color
    ask patch-at 0 0 [set pcolor c ]
    set moves_since_fork (moves_since_fork + 1)
    let newx (xcor + xrel)
    let newy (ycor + yrel)
    let r  sqrt ( newx * newx + newy * newy)
    ;;show word  "radius=" r
    if r < max_radius [
      set xcor newx
      set ycor newy
      ;;forks
      if breed = lefties and moves_since_fork = 4 and must_fork_right [
        ;les Left se décalent de 0 1 et fork a droite tous les 4
        ;show "Forking left to right"
        set must_fork_right false
        set moves_since_fork 0
        let x xcor
        let y ycor
        hatch-lefties 1 [
          set xrel 0
          set yrel 1
          set color random-normal blue sigma
          set xcor x + 1
          set ycor y + 0
          set must_fork_left false
          set must_fork_right true
        ]
      ]
      if breed = righties and moves_since_fork = 3 and must_fork_left[
        ;les Right se décalent de 1,1 et fork a gauche tous les 3
        ;show "Forking right to left"
        set must_fork_left false
        set moves_since_fork 0
        let x xcor
        let y ycor
        hatch-righties 1 [
          set xrel 1
          set yrel 1
          set color random-normal orange sigma
          set xcor x + 0
          set ycor y + 1
          set must_fork_left true
          set must_fork_right false
        ]
      ]
      if breed = centers and moves_since_fork = 2  [
        let cc color
        ;les Center se décalent de 1,2 et fork tous les 2
        if must_fork_left[
          ;show "Forking center to left "
          set must_fork_left false
          set moves_since_fork 0
          let x xcor
          let y ycor
          hatch-centers 1 [
            set xrel 1
            set yrel 2
            set color random-normal cc sigma
            set xcor x - 1
            set ycor y + 0
            set must_fork_left true
            set must_fork_right false
          ]
        ]
        if must_fork_right [
          ;show "Forking center to right "
          set must_fork_right false
          set moves_since_fork 0
          let x xcor
          let y ycor
          hatch-centers 1 [
            set xrel 1
            set yrel 2
            set color random-normal cc sigma
            set xcor x + 1
            set ycor y + 0
            set must_fork_left false
            set must_fork_right true
          ]
        ]
      ]
    ]
  ]
end 

There is only one version of this model, created almost 4 years ago by Thomas Bronner.

Attached files

File Type Description Last updated
Radial path.png preview Preview for 'Radial path' almost 4 years ago, by Thomas Bronner Download

This model does not have any ancestors.

This model does not have any descendants.