Rock Paper Scissors (Random vs 4)

Rock Paper Scissors (Random vs 4) 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 67 times • Downloaded 3 times • Run 0 times
Download the 'Rock Paper Scissors (Random vs 4)' 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 [
  player2-score           ;;violet left
  player3-score           ;;yellow center-left
  player4-score           ;;pink center-right
  player5-score           ;;blue right

  game-number
  pause-time

  tie-counter-player2
  tie-counter-player3
  tie-counter-player4
  tie-counter-player5

  player1-score-vs-player2
  player1-score-vs-player3
  player1-score-vs-player4
  player1-score-vs-player5
]

turtles-own [
  state
]

to setup
  clear-all
  reset-scores

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

    if who = 4 [                                           ;;Opponent Article-recommended Strat turtle
      setxy 2 0.5
      set color blue
      set shape "unknown"
      facexy 0 3
    ]
  ]

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

    if who = 9 [                                           ;;Opponent Article-recommended Strat turtle
      setxy 2.8 0
      set color blue
      set shape "person"
    ]
  ]

  reset-ticks
end 

to go
  ask turtles with [who >= 0 and who <= 3] [
     set state one-of ["rock" "paper" "scissors"]          ;; Initial hand of all
     set-shape
     facexy 1 3                                            ;; Let player 1 face top right
  ]

  ask turtles with [who >= 1 and who <= 4] [
    facexy 0 2                                             ;; Let the other players face towards player 1
  ]

  ask turtles with [who = 4] [
     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
   let player5-choice [state] of turtle 4

   ask turtle 1 [                                           ;;Opponent Random Strat turtle
     if player1-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 player1-score-vs-player2 player1-score-vs-player2 + 1
           set color red
         ]
       ]
       if player2-choice = "rock" [
         if who = 1 [
           set tie-counter-player2 tie-counter-player2 + 1
           set color gray
         ]
       ]
     ]


     if player1-choice = "paper" [
       if player2-choice = "rock" [
         if who = 1 [
           set player1-score-vs-player2 player1-score-vs-player2 + 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 tie-counter-player2 + 1
           set color gray
         ]
       ]
     ]


     if player1-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 player1-score-vs-player2 player1-score-vs-player2 + 1
           set color red
         ]
       ]
       if player2-choice = "scissors" [
         if who = 1 [
           set tie-counter-player2 tie-counter-player2 + 1
           set color gray
         ]
       ]
     ]
   ]

   ask turtle 2 [                                           ;;Opponent Win-Stay Lose-Change Strat turtle
     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 player1-score-vs-player3 player1-score-vs-player3 + 1
           set color red
         ]
       ]
       if player3-choice = "rock" [
         if who = 2 [
           set tie-counter-player3 tie-counter-player3 + 1
           set color gray
         ]
       ]
     ]


     if player1-choice = "paper" [
       if player3-choice = "rock" [
         if who = 2 [
           set player1-score-vs-player3 player1-score-vs-player3 + 1
           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 tie-counter-player3 tie-counter-player3 + 1
           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 player1-score-vs-player3 player1-score-vs-player3 + 1
           set color red
         ]
       ]
       if player3-choice = "scissors" [
         if who = 2 [
           set tie-counter-player3 tie-counter-player3 + 1
           set color gray
         ]
       ]
     ]
   ]

   ask turtle 3 [                                           ;;Opponent Win-Change Lose-Stay Strat turtle
     if player1-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 player1-score-vs-player4 player1-score-vs-player4 + 1
           set color red
         ]
       ]
       if player4-choice = "rock" [
         if who = 3 [
           set tie-counter-player4 tie-counter-player4 + 1
           set color gray
         ]
       ]
     ]


     if player1-choice = "paper" [
       if player4-choice = "rock" [
         if who = 3 [
           set player1-score-vs-player4 player1-score-vs-player4 + 1
           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 tie-counter-player4 tie-counter-player4 + 1
           set color gray
         ]
       ]
     ]


     if player1-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 player1-score-vs-player4 player1-score-vs-player4 + 1
           set color red
         ]
       ]
       if player4-choice = "scissors" [
         if who = 3 [
           set tie-counter-player4 tie-counter-player4 + 1
           set color gray
         ]
       ]
     ]
   ]

   ask turtle 4 [                                           ;;Opponent Article-recommended Strat turtle
     if player1-choice = "rock" [
       if player5-choice = "paper" [
         if who = 4 [
           set player5-score player5-score + 1
           set color green
         ]
       ]
       if player5-choice = "scissors" [
         if who = 4 [
           set player1-score-vs-player5 player1-score-vs-player5 + 1
           set color red
         ]
       ]
       if player5-choice = "rock" [
         if who = 4 [
           set tie-counter-player5 tie-counter-player5 + 1
           set color gray
         ]
       ]
     ]


     if player1-choice = "paper" [
       if player5-choice = "rock" [
         if who = 4 [
           set player1-score-vs-player5 player1-score-vs-player5 + 1
           set color red

         ]
       ]
       if player5-choice = "scissors" [
         if who = 4 [
           set player5-score player5-score + 1
           set color green
         ]
       ]
       if player5-choice = "paper" [
         if who = 4 [
           set tie-counter-player5 tie-counter-player5 + 1
           set color gray
         ]
       ]
     ]


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

   set game-number game-number + 1
   set pause-time 1 / game-per-second
   tick
   wait pause-time

   ask turtles with [who >= 0 and who <= 1] [               ;;Next hand for player 1 and player 2 since they are both random
    set state one-of ["rock" "paper" "scissors"]
    set-shape
  ]
                                                            ;; Next state/hand portion for player 3 and player 4

   ask turtle 2 [                                           ;;Opponent Win-Stay Lose-Change Strat turtle
     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 ["scissors" "paper"]
           set-shape
         ]
       ]
     ]


     if player1-choice = "paper" [
       if player3-choice = "rock" [
         if who = 2 [
           set state one-of ["scissors" "paper"]
           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 ["scissors" "rock"]
           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 ["paper" "rock"]
           set-shape
         ]
       ]
     ]
   ]

   ask turtle 3 [                                           ;;Opponent Win-Change Lose-Stay Strat turtle
     if player1-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 player1-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 player1-choice = "scissors" [
       if player4-choice = "rock" [
          if who = 3 [
           set state one-of ["paper" "scissors"]
           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
         ]
       ]
     ]
   ]

   ask turtle 4 [                                           ;;Opponent Article-recommended Strat turtle
     if player1-choice = "rock" [
       if player5-choice = "paper" [
         if who = 4 [
           set state "rock"
           set-shape
         ]
       ]
       if player5-choice = "scissors" [
         if who = 4 [
           set state "paper"
           set-shape
         ]
       ]
       if player5-choice = "rock" [
         if who = 4 [
           set state one-of ["paper" "scissors"]
           set-shape
         ]
       ]
     ]


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


     if player1-choice = "scissors" [
       if player5-choice = "rock" [
          if who = 4 [
           set state "scissors"
           set-shape
         ]
       ]
       if player5-choice = "paper" [
         if who = 4 [
           set state "rock"
           set-shape
         ]
       ]
       if player5-choice = "scissors" [
         if who = 4 [
           set state one-of ["rock" "paper"]
           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 who = 4 [
    set color blue
  ]

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

to reset-scores
  set player2-score 0
  set player3-score 0
  set player4-score 0
  set player5-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 (Random vs 4).png preview Preview for 'Rock Paper Scissors (Random vs 4)' 7 months ago, by Zeus Morley Pineda Download

This model does not have any ancestors.

This model does not have any descendants.