Rock Scissors Paper Competitive Environment

Rock Scissors Paper Competitive Environment preview image

1 collaborator

Default-person Rashid Mhar (Author)

Tags

algae 

Tagged by Rashid Mhar about 10 years ago

artificial life 

Tagged by Rashid Mhar about 10 years ago

game of life 

Tagged by Rashid Mhar about 10 years ago

rock paper scissors 

"based on the game"

Tagged by Rashid Mhar about 10 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 5.1.0 • Viewed 472 times • Downloaded 39 times • Run 0 times
Download the 'Rock Scissors Paper Competitive Environment' 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

Click to Run Model

globals [ colist rockbred rockspawn scissorbred scissorspawn paperbred paperspawn rockkill scissorkill paperkill ]
turtles-own [ energy adjust ]
breed [ rocks rock ]
breed [ papers paper ]
breed [ scissors scissor ]

to setup

  clear-all
  set colist (list random 255 random 255 random 255)
  ask patches
  [
    set pcolor black
  ]
  create-rocks number-rocks
  [
    create "rockblob" red - 1
  ]
  create-papers number-papers
  [
    create "paperblob" lime - 1
  ]
  create-scissors number-scissors
  [
    create "scissorblob" blue - 1
  ]
  reset-ticks
end 

to create [form col]
  set shape form
  setxy random-xcor random-ycor
  right random 360
  set color col
end 

to go
  if (ticks >= duration) and Timed [ stop ]  ;; stop after set duration of ticks
  ask turtles
  [
    ifelse Draw [pendown][pen-erase]
  ]
  resources
  moveall
  feed
  kills
  reproduce
  if respawn-interval > 0 [ respawns ] ;; switch off respawns of interval zero
  tick
end 

to moveall
  if r-hunt [ hunt rocks]
  if s-hunt [ hunt scissors]
  if p-hunt [ hunt papers]
  if r-find [ find rocks ]
  if s-find [ find scissors ]
  if p-find [ find papers ]
  if r-evade [ evade rocks]
  if s-evade [ evade scissors]
  if p-evade [ evade papers]
  if r-avoid [ avoid rocks]
  if s-avoid [ avoid scissors]
  if p-avoid [ avoid papers]
  move rocks rock%
  move scissors scissor%
  move papers paper%
end 

to move [brd var]
  ask brd
  [
    forward 0.01 * speed * (var / 100)
  ]
end 

to kills
  ask papers
  [
    if predation and p-gain [ set energy energy + (count rocks-here) * predation-gain ]
    ask rocks-here
    [
      set rockkill rockkill + 1
      die
    ]
  ]
  ask rocks
  [
    if predation and r-gain [ set energy energy + (count scissors-here) * predation-gain ]
    ask scissors-here
    [
      set scissorkill scissorkill + 1
      die
    ]
  ]
  ask scissors
  [
    if predation and s-gain [ set energy energy + (count papers-here) * predation-gain ]
    ask papers-here
    [
      set paperkill paperkill + 1
      die
    ]
  ]
end 

to resources
  ask patches
  [
    let erg-available random 100
    if (erg-available < energy-input-chance) and (ticks mod energy-input-delay = 0)
    [
      set pcolor black + 1
    ]
  ]
end 

to feed
  ask turtles [
    if pcolor = black + 1 [
      set pcolor black
      set energy energy + 1
    ]
  ifelse show-energy
    [ set label energy ] ;; the label is set to be the value of the energy
    [ set label "" ]     ;; the label is set to an empty text value
  ]
end 

to reproduce
  ask rocks
  [
    set adjust rocks+
  ]
  ask scissors
  [
    set adjust scissors+
  ]
  ask papers
  [
    set adjust papers+
  ]
  ask turtles [
    if energy > (reproduction-energy + adjust)[
      set energy energy - (reproduction-energy + adjust)  ;; take away reproduction-energy for mitosis
      hatch 1 [
        right random 360
      if breed = rocks
      [ set rockbred rockbred + 1 ]
      if breed = scissors
      [ set scissorbred scissorbred + 1 ]
      if breed = papers
      [ set paperbred paperbred + 1 ]
      ]
    ]
  ]
end 

to respawns
  if ticks mod respawn-interval = 0
  [
    create-rocks 1
    [
      create "rockblob" red - 1
      set rockspawn rockspawn + 1
    ]
    create-papers 1
    [
      create "paperblob" lime - 1
      set paperspawn paperspawn + 1
    ]
    create-scissors 1
    [
      create "scissorblob" blue - 1
      set scissorspawn scissorspawn + 1
    ]
  ]
end 

to hunt [brd]
  if brd = rocks
  [
    ask brd
    [
      let found (one-of scissors-on neighbors)
      if found != nobody [set heading towards found]
    ]
  ]
  if brd = scissors
  [
    ask brd
    [
      let found (one-of papers-on neighbors)
      if found != nobody [set heading towards found]
    ]
  ]
  if brd = papers
  [
    ask brd
    [
      let found (one-of rocks-on neighbors)
      if found != nobody [set heading towards found]
    ]
  ]
end 

to evade [brd]
  if brd = rocks
  [
    ask brd
    [
      let found (one-of papers-on neighbors)
      if found != nobody [set heading (towards found + 180)]
    ]
  ]
  if brd = scissors
  [
    ask brd
    [
      let found (one-of rocks-on neighbors)
      if found != nobody [set heading (towards found + 180)]
    ]
  ]
  if brd = papers
  [
    ask brd
    [
      let found (one-of scissors-on neighbors)
      if found != nobody [set heading (towards found + 180)]
    ]
  ]
end 

to avoid [brd]
  if brd = rocks
  [
    ask brd
    [
      let found (one-of scissors-on neighbors)
      if found != nobody [set heading (towards found + 180)]
    ]
  ]
  if brd = scissors
  [
    ask brd
    [
      let found (one-of papers-on neighbors)
      if found != nobody [set heading (towards found + 180)]
    ]
  ]
  if brd = papers
  [
    ask brd
    [
      let found (one-of rocks-on neighbors)
      if found != nobody [set heading (towards found + 180)]
    ]
  ]
end 

to find [brd]
  ask brd
  [
    let found (one-of neighbors with [ pcolor = black + 1 ])
    if found != nobody [set heading towards found]
  ]
end 

to reset
  set rock% 100
  set scissor% 100
  set paper% 100
  
  set rocks+ 0
  set scissors+ 0
  set papers+ 0
end 

There is only one version of this model, created about 10 years ago by Rashid Mhar.

Attached files

File Type Description Last updated
Rock Scissors Paper Competitive Environment.png preview Preview for 'Rock Scissors Paper Competitive Environment' about 10 years ago, by Rashid Mhar Download

This model does not have any ancestors.

This model does not have any descendants.