MIHS-18 Period 6 Ethan T, Brian P

No preview image

1 collaborator

Default-person Ethan Torok (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.4 • Viewed 75 times • Downloaded 11 times • Run 0 times
Download the 'MIHS-18 Period 6 Ethan T, Brian P' 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

globals [
  max-viruses
]

turtles-own [
  mass ;; affects diffusion speeds
]

patches-own [
  is-Cell? ;; virus reproduction site
  is-Infected?
  pDeathTimer ;; time until death and release of viruses
  pDivideTimer ;; time until division into neighboring non-cell patch
]

breed [Macrophages Macrophage]
breed [Viruses Virus]
breed [Antibodies Antibody]

Antibodies-own [
  connected-VirusA?
  connected-VirusB?
  connected-VirusC?
  connected-VirusD?
]

Macrophages-own [
  activatedEnergy
  divideTimer
]

to setup
  clear-all

  resize-world -25 25 -25 25
  set-patch-size 8
  set max-viruses 1000

  ask patches [
    set is-Cell? false
    set is-Infected? false
  ]

  make-cells -20 -20
  make-cells 20 15

  create-Macrophages initial-number-Macrophages [
    set shape "circle"
    set color blue
    set size 5
    set mass 30
    set activatedEnergy 0
    set divideTimer 100
    setxy random-xcor random-ycor
  ]

  create-Viruses initial-number-Viruses [
    set shape "default"
    set color white
    set size 1
    set mass 10
    setxy random-xcor random-ycor
  ]

  create-Antibodies initial-number-Antibodies [
    set shape "pentagon"
    set color yellow
    set size 1
    set mass 1
    setxy random-xcor random-ycor
  ]

  reset-ticks
end 

to move
  set heading random 360
  forward 2 / mass
end 

to go

  ask Macrophages [
    eat-viruses
    move
  ]
  ask Antibodies [
    move
  ]
  ask patches [
    lyse
    divide
  ]
ask Viruses [
    move
    infect-cell
  ]
  tick
end 

to infect-cell
  if [is-Cell?] of patch-here and not [is-Infected?] of patch-here [ ;; if healthy
    ask patch-here [
      set is-Infected? true
      set pColor red
    ]
    die
  ]
end 

to make-cells [x y]
  ask patches [
    if (distancexy x y) <= 5 [
      spawn-cell pxcor pycor
    ]
  ]
end 

to spawn-cell [x y]
  ask patch x y [
    set pcolor green
    set is-Cell? true
    set pDivideTimer cell-division-speed + random cell-division-speed / 3 - random cell-division-speed / 3
    set pDeathTimer cell-death-speed + random cell-death-speed / 3 - random cell-death-speed / 3
  ]
end 

to divide
  if is-Cell? and not is-Infected? [ ;; if healthy
    ifelse pDivideTimer <= 0 and (any? neighbors with [pcolor = black]) [
      let cellPatch one-of neighbors with [pcolor = black]
      spawn-cell [pxcor] of cellPatch [pycor] of cellPatch
      spawn-cell pxcor pycor
    ] [
      set pDivideTimer pDivideTimer - 1
    ]
  ]
end 

to lyse
  if is-Cell? and is-Infected? [
    ifelse pDeathTimer <= 0
    [
      set is-Cell? not is-Cell?
      set is-Infected? not is-Infected?
      set pcolor black

      if count Viruses < max-viruses [
        sprout-Viruses viruses-produced-after-infection [
          set shape "default"
          set color white
          set size 1
          set mass 10
          setxy pxcor pycor
        ]
      ]
    ]
    [
      set pDeathTimer pDeathTimer - 1
    ]
  ]
end 

to eat-viruses
  ask Viruses in-radius 5
  [die]
end 

There is only one version of this model, created over 5 years ago by Ethan Torok.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.