Rock Paper Scissors

Rock Paper Scissors preview image

1 collaborator

Default-person Carolina Crespi (Author)

Tags

rock paper scissors 

Tagged by Carolina Crespi 5 days ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.3.0 • Viewed 33 times • Downloaded 4 times • Run 0 times
Download the 'Rock Paper Scissors' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model simulates the classic game of Rock-Paper-Scissors in a spatial environment using agents. Each agent represents either a rock, paper, or scissors and moves randomly in the environment. When two agents come into contact, they interact according to the traditional game rules. The simulation continues until one type dominates the entire population. This model provides a simple yet powerful example of local interactions and dominance dynamics in a multi-agent system.

HOW IT WORKS

Each agent has a specific shape and color:

  • Rock → gray
  • Paper → green
  • Scissors → blue

Agents move via a pure random walk at each tick. When two agents come within radius 1 of each other, they interact according to the Rock-Paper-Scissors rules:

  • Rock beats Scissors → Scissors becomes Rock
  • Scissors beats Paper → Paper becomes Scissors
  • Paper beats Rock → Rock becomes Paper

Only the losing agent changes its type and color. The interaction is one-sided per tick: a turtle detects a nearby neighbor and converts it if it wins. The process continues until all agents are of the same type.

HOW TO USE IT

Use the sliders to set the initial number of each agent type: num-rock, num-paper, and num-scissor.

Press Setup to initialize the agents in random positions.

Press Go to start the simulation. Agents will begin moving randomly and interacting based on the rules above.

The simulation automatically stops when the entire population has converged to a single type. You can also stop it manually at any time.

The plot tracks the population count of each type over time. The three monitors show the current count of each type in real time.

THINGS TO NOTICE

Which type tends to dominate in different configurations?

Does the system converge faster when one type starts in the majority?

Are there cases where the outcome is not determined by the initial majority?

How long does it take, on average, for convergence with equal starting numbers?

THINGS TO TRY

Try unbalanced initial populations (e.g., many rocks and few papers).

Start with equal numbers of all three types and run multiple times. Does the outcome vary?

Set one type to 0 and observe the trivial two-type dynamics.

CREDITS AND REFERENCES

Model created by Carolina Crespi, Research Fellow in Computer Science, Department of Mathematics and Computer Science, University of Catania.

Research interests: swarm intelligence, collective behaviors, agent-based models, autonomous navigation in unknown environments, optimization.

If used in academic or educational contexts, please cite appropriately.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

to setup
  clear-all
  setup-turtles
  reset-ticks
  ; Light gray background for better visibility
  ask patches [ set pcolor 9.5 ]
end 

to setup-turtles
  ; Create agents for each type with their assigned shape and color
  create-turtles num-paper [
    set color green
    set shape "paper"
    set size 3
    setxy random-xcor random-ycor
  ]
  create-turtles num-scissor [
    set color blue
    set shape "scissor"
    set size 3
    setxy random-xcor random-ycor
  ]
  create-turtles num-rock [
    set color gray
    set shape "rock"
    set size 3
    setxy random-xcor random-ycor
  ]
end 

to go
  ; Each turtle moves first, then interactions are evaluated
  ask turtles [ move ]
  ask turtles [ check-collision ]

  ; Stop the simulation when one type has taken over the entire population
  if all-turtles-same-shape? [ stop ]
  tick
end 

; Returns true when all agents have converged to the same type

to-report all-turtles-same-shape?
  let rock-count count turtles with [shape = "rock"]
  let paper-count count turtles with [shape = "paper"]
  let scissor-count count turtles with [shape = "scissor"]
  report (rock-count = count turtles or paper-count = count turtles or scissor-count = count turtles)
end 

to move
  ; Pure random walk: rotate by a random angle and step forward
  rt random 360
  fd 1
end 

to check-collision
  let nearby-turtle one-of other turtles in-radius 1
  if nearby-turtle != nobody [
    let nearby-shape [shape] of nearby-turtle

    ; Rock beats Scissors: scissors becomes rock
    if (shape = "rock" and nearby-shape = "scissor") [
      ask nearby-turtle [ set shape "rock" set color gray ]
    ]

    ; Paper beats Rock: rock becomes paper
    if (shape = "paper" and nearby-shape = "rock") [
      ask nearby-turtle [ set shape "paper" set color green ]
    ]

    ; Scissors beats Paper: paper becomes scissors
    if (shape = "scissor" and nearby-shape = "paper") [
      ask nearby-turtle [ set shape "scissor" set color blue ]
    ]
  ]
end 

There is only one version of this model, created 5 days ago by Carolina Crespi.

Attached files

File Type Description Last updated
Rock Paper Scissors.png preview Preview for 'Rock Paper Scissors' 5 days ago, by Carolina Crespi Download

This model does not have any ancestors.

This model does not have any descendants.