Rock Paper Scissors (Article vs 2)

Rock Paper Scissors (Article vs 2) preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.4.0 • Viewed 81 times • Downloaded 1 time • Run 0 times
Download the 'Rock Paper Scissors (Article vs 2)' 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 [
  player1-score           ;;violet top-left
  player2-score           ;;yellow top-right
  player3-score           ;;pink bottom-left
  player4-score           ;;blue bottom-right

  game-number
  pause-time

  tie-counter-player1-vs-player3
  tie-counter-player2-vs-player4
]

turtles-own [
  state
]

to setup
  clear-all
  reset-scores

  create-turtles 4 [
    if who = 0 [                                           ;;Article-Based Strat turtle #1
      setxy -2 1.5
      set color white
      set shape "unknown"
      facexy -2 -2
    ]
    if who = 1 [                                           ;;Article-Based Strat turtle #2
      setxy 2 1.5
      set color violet
      set shape "unknown"
      facexy 2 -2
    ]
    if who = 2 [                                           ;;Opponent Win-Stay Lose-Change Strat turtle
      setxy -2 -1.5
      set color yellow
      set shape "unknown"
      facexy -2 2
    ]
    if who = 3 [                                           ;;Opponent Win-Change Lose-Stay Strat turtle
      setxy 2 -1.5
      set color pink
      set shape "unknown"
      facexy 2 2
    ]
  ]

  create-turtles 4 [
    if who = 4 [                                           ;;Random Strat turtle
      setxy -2 2.5
      set color white
      set shape "person"
    ]
    if who = 5 [                                           ;;Opponent Random Strat turtle
      setxy 2 2.5
      set color violet
      set shape "person"
    ]
    if who = 6 [                                           ;;Opponent Win-Stay Lose-Change Strat turtle
      setxy -2 -2.5
      set color yellow
      set shape "person"
    ]
    if who = 7 [                                           ;;Opponent Win-Change Lose-Stay Strat turtle
      setxy 2 -2.5
      set color pink
      set shape "person"
    ]
  ]

  reset-ticks
end 

to go
  ask turtles with [who >= 2 and who <= 3] [
     set state one-of ["rock" "paper" "scissors"]          ;; Initial hand for WsLc and WcLs
     set-shape
  ]

  ask turtles with [who >= 0 and who <= 1] [                 ;; Initial hand for player 1 and 2
     set state one-of ["paper"]
     set-shape
  ]


  while [game-number < number-of-games] [
   if game-number = number-of-games[
     stop
   ]
                                                           ;; Points counting portion
   let player1-choice [state] of turtle 0
   let player2-choice [state] of turtle 1
   let player3-choice [state] of turtle 2
   let player4-choice [state] of turtle 3

   ask turtle 0 [                                           ;;Article-Based #1 vs Win-Stay/Lose-Change
     if player3-choice = "rock" [
       if player1-choice = "paper" [
         if who = 0 [
           set player1-score player1-score + 1
           set color green
         ]
       ]
       if player1-choice = "scissors" [
         if who = 0 [
           set color red
         ]
       ]
       if player1-choice = "rock" [
         if who = 0 [
           set tie-counter-player1-vs-player3 tie-counter-player1-vs-player3 + 1
           set color gray
         ]
       ]
     ]


     if player3-choice = "paper" [
       if player1-choice = "rock" [
         if who = 0 [
           set color red
         ]
       ]
       if player1-choice = "scissors" [
         if who = 0 [
           set player1-score player1-score + 1
           set color green
         ]
       ]
       if player1-choice = "paper" [
         if who = 0 [
           set tie-counter-player1-vs-player3 tie-counter-player1-vs-player3 + 1
           set color gray
         ]
       ]
     ]


     if player3-choice = "scissors" [
       if player1-choice = "rock" [
          if who = 0 [
           set player1-score player1-score + 1
           set color green
         ]
       ]
       if player1-choice = "paper" [
         if who = 0 [
           set color red
         ]
       ]
       if player1-choice = "scissors" [
         if who = 0 [
           set tie-counter-player1-vs-player3 tie-counter-player1-vs-player3 + 1
           set color gray
         ]
       ]
     ]
   ]

   ask turtle 1 [                                           ;;Article-Based #2 vs Win-Change/Lose-Stay
     if player4-choice = "rock" [
       if player2-choice = "paper" [
         if who = 1 [
           set player2-score player2-score + 1
           set color green
         ]
       ]
       if player2-choice = "scissors" [
         if who = 1 [
           set color red
         ]
       ]
       if player2-choice = "rock" [
         if who = 1 [
           set tie-counter-player2-vs-player4 tie-counter-player2-vs-player4 + 1
           set color gray
         ]
       ]
     ]


     if player4-choice = "paper" [
       if player2-choice = "rock" [
         if who = 1 [
           set color red
         ]
       ]
       if player2-choice = "scissors" [
         if who = 1 [
           set player2-score player2-score + 1
           set color green
         ]
       ]
       if player2-choice = "paper" [
         if who = 1 [
           set tie-counter-player2-vs-player4 tie-counter-player2-vs-player4 + 1
           set color gray
         ]
       ]
     ]


     if player4-choice = "scissors" [
       if player2-choice = "rock" [
          if who = 1 [
           set player2-score player2-score + 1
           set color green
         ]
       ]
       if player2-choice = "paper" [
         if who = 1 [
           set color red
         ]
       ]
       if player2-choice = "scissors" [
         if who = 1 [
           set tie-counter-player2-vs-player4 tie-counter-player2-vs-player4 + 1
           set color gray
         ]
       ]
     ]
   ]

   ask turtle 2 [                                           ;; Win-Stay/Lose-Change vs Article-Based #1
     if player1-choice = "rock" [
       if player3-choice = "paper" [
         if who = 2 [
           set player3-score player3-score + 1
           set color green
         ]
       ]
       if player3-choice = "scissors" [
         if who = 2 [
           set color red
         ]
       ]
       if player3-choice = "rock" [
         if who = 2 [
           set color gray
         ]
       ]
     ]


     if player1-choice = "paper" [
       if player3-choice = "rock" [
         if who = 2 [
           set color red
         ]
       ]
       if player3-choice = "scissors" [
         if who = 2 [
           set player3-score player3-score + 1
           set color green
         ]
       ]
       if player3-choice = "paper" [
         if who = 2 [
           set color gray
         ]
       ]
     ]


     if player1-choice = "scissors" [
       if player3-choice = "rock" [
          if who = 2 [
           set player3-score player3-score + 1
           set color green
         ]
       ]
       if player3-choice = "paper" [
         if who = 2 [
           set color red
         ]
       ]
       if player3-choice = "scissors" [
         if who = 2 [
           set color gray
         ]
       ]
     ]
   ]

   ask turtle 3 [                                           ;; Win-Change/Lose-Stay vs Article-Based #2
     if player2-choice = "rock" [
       if player4-choice = "paper" [
         if who = 3 [
           set player4-score player4-score + 1
           set color green
         ]
       ]
       if player4-choice = "scissors" [
         if who = 3 [
           set color red
         ]
       ]
       if player4-choice = "rock" [
         if who = 3 [
           set color gray
         ]
       ]
     ]


     if player2-choice = "paper" [
       if player4-choice = "rock" [
         if who = 3 [
           set color red
         ]
       ]
       if player4-choice = "scissors" [
         if who = 3 [
           set player4-score player4-score + 1
           set color green
         ]
       ]
       if player4-choice = "paper" [
         if who = 3 [
           set color gray
         ]
       ]
     ]


     if player2-choice = "scissors" [
       if player4-choice = "rock" [
          if who = 3 [
           set player4-score player4-score + 1
           set color green
         ]
       ]
       if player4-choice = "paper" [
         if who = 3 [
           set color red
         ]
       ]
       if player4-choice = "scissors" [
         if who = 3 [
           set color gray
         ]
       ]
     ]
   ]

   set game-number game-number + 1
   set pause-time 1 / game-per-second
   tick
   wait pause-time
                                                            ;; Next state/hand portion

   ask turtle 0 [                                           ;;Article-Based #1 vs Win-Stay/Lose-Change
     if player3-choice = "rock" [
       if player1-choice = "paper" [
         if who = 0 [
           set state "rock"
           set-shape
         ]
       ]
       if player1-choice = "scissors" [
         if who = 0 [
           set state "paper"
           set-shape
         ]
       ]
       if player1-choice = "rock" [
         if who = 0 [
           set state one-of ["paper" "scissors"]
           set-shape
         ]
       ]
     ]


     if player3-choice = "paper" [
       if player1-choice = "rock" [
         if who = 0 [
           set state "scissors"
           set-shape
         ]
       ]
       if player1-choice = "scissors" [
         if who = 0 [
           set state "rock"
           set-shape
         ]
       ]
       if player1-choice = "paper" [
         if who = 0 [
           set state one-of ["rock" "scissors"]
           set-shape
         ]
       ]
     ]


     if player3-choice = "scissors" [
       if player1-choice = "rock" [
          if who = 0 [
           set state "scissors"
           set-shape
         ]
       ]
       if player1-choice = "paper" [
         if who = 0 [
           set state "rock"
           set-shape
         ]
       ]
       if player1-choice = "scissors" [
         if who = 0 [
           set state one-of ["rock" "paper"]
           set-shape
         ]
       ]
     ]
   ]

   ask turtle 1 [                                           ;;Article-Based #2 vs Win-Change/Lose-Stay
     if player4-choice = "rock" [
       if player2-choice = "paper" [
         if who = 1 [
           set state "rock"
           set-shape
         ]
       ]
       if player2-choice = "scissors" [
         if who = 1 [
           set state "paper"
           set-shape
         ]
       ]
       if player2-choice = "rock" [
         if who = 1 [
           set state one-of ["scissors" "paper"]
           set-shape
         ]
       ]
     ]


     if player4-choice = "paper" [
       if player2-choice = "rock" [
         if who = 1 [
           set state "scissors"
           set-shape
         ]
       ]
       if player2-choice = "scissors" [
         if who = 1 [
           set state "paper"
           set-shape
         ]
       ]
       if player2-choice = "paper" [
         if who = 1 [
           set state one-of ["rock" "scissors"]
           set-shape
         ]
       ]
     ]


     if player4-choice = "scissors" [
       if player2-choice = "rock" [
          if who = 1 [
           set state "scissors"
           set-shape
         ]
       ]
       if player2-choice = "paper" [
         if who = 1 [
           set state "rock"
           set-shape
         ]
       ]
       if player2-choice = "scissors" [
         if who = 1 [
            set state one-of ["rock" "paper"]
            set-shape
         ]
       ]
     ]
   ]

   ask turtle 2 [                                           ;;Win-Stay/Lose-Change vs Article-Based #1
     if player1-choice = "rock" [
       if player3-choice = "paper" [
         if who = 2 [
           ;;set state "paper"
           set-shape
         ]
       ]
       if player3-choice = "scissors" [
         if who = 2 [
           set state one-of ["rock" "paper"]
           set-shape
         ]
       ]
       if player3-choice = "rock" [
         if who = 2 [
           set state one-of ["paper" "scissors"]
           set-shape
         ]
       ]
     ]


     if player1-choice = "paper" [
       if player3-choice = "rock" [
         if who = 2 [
           set state one-of ["paper" "scissors"]
           set-shape
         ]
       ]
       if player3-choice = "scissors" [
         if who = 2 [
           ;;set state "scissors"
           set-shape
         ]
       ]
       if player3-choice = "paper" [
         if who = 2 [
           set state one-of ["rock" "scissors"]
           set-shape
         ]
       ]
     ]


     if player1-choice = "scissors" [
       if player3-choice = "rock" [
          if who = 2 [
           ;;set state "rock"
           set-shape
         ]
       ]
       if player3-choice = "paper" [
         if who = 2 [
           set state one-of ["scissors" "rock"]
           set-shape
         ]
       ]
       if player3-choice = "scissors" [
         if who = 2 [
           set state one-of ["rock" "paper"]
           set-shape
         ]
       ]
     ]
   ]

   ask turtle 3 [                                           ;;Win-Change/Lose-Stay vs Article-Based #1
     if player2-choice = "rock" [
       if player4-choice = "paper" [
         if who = 3 [
           set state one-of ["rock" "scissors"]
           set-shape
         ]
       ]
       if player4-choice = "scissors" [
         if who = 3 [
           ;;set state "scissors"
           set-shape
         ]
       ]
       if player4-choice = "rock" [
         if who = 3 [
           ;;set state "rock"
           set-shape
         ]
       ]
     ]


     if player2-choice = "paper" [
       if player4-choice = "rock" [
         if who = 3 [
           ;;set state "rock"
           set-shape
         ]
       ]
       if player4-choice = "scissors" [
         if who = 3 [
           set state one-of ["rock" "paper"]
           set-shape
         ]
       ]
       if player4-choice = "paper" [
         if who = 3 [
           ;;set state "paper"
           set-shape
         ]
       ]
     ]


     if player2-choice = "scissors" [
       if player4-choice = "rock" [
          if who = 3 [
           set state one-of ["scissors" "paper"]
           set-shape
         ]
       ]
       if player4-choice = "paper" [
         if who = 3 [
           ;;set state "paper"
           set-shape
         ]
       ]
       if player4-choice = "scissors" [
         if who = 3 [
           ;;set state "scissors"
           set-shape
         ]
       ]
     ]
   ]
 ]
end 

to set-shape
  if who = 0 [
    set color white
  ]

  if who = 1 [
    set color violet
  ]

  if who = 2 [
    set color yellow
  ]

  if who = 3 [
    set color pink
  ]

  if state = "rock" [
    set shape "rock"
  ]
  if state = "paper" [
     set shape "paper"
  ]
  if state = "scissors" [
     set shape "scissors"
  ]
end 

to reset-scores
  set player1-score 0
  set player2-score 0
  set player3-score 0
  set player4-score 0
end 

There is only one version of this model, created 7 months ago by Zeus Morley Pineda.

Attached files

File Type Description Last updated
Rock Paper Scissors (Article vs 2).png preview Preview for 'Rock Paper Scissors (Article vs 2)' 7 months ago, by Zeus Morley Pineda Download

This model does not have any ancestors.

This model does not have any descendants.