# Game Theory UHON 111 SP24

Model was written in NetLogo 5.3.1
•
Viewed 112 times
•
Downloaded 25 times
•
Run 0 times

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

breed [ titles title ] breed [ opponents opponent ] globals [ player-score opponent-score playerchoice opponentchoice game-outcome initial-play iteration unknown-strategy ] to setup clear-all reset-ticks create-turtles 4 [ set color black make-labels ] ask turtle 0 [ setxy 5 4 ] ask turtle 1 [ setxy 5 -4 ] ask turtle 2 [ setxy -3 -4 ] ask turtle 3 [ setxy -3 4 ] draw-lines generate-titles generate-opponent setup-scores end ;;;;;;;;;;;;;; ;; ;; ;; GO STUFF ;; ;; ;; ;;;;;;;;;;;;;; to play play-a-choice calculate-payoffs tick wait 0.1 plot-results if (ticks > 99) [ stop ] end to play-a-choice ;; Find player 1 strategy set opponentchoice 0 let opponent-choice "Null" ifelse (unknown-strategy = 0) [ if (opponent-strategy = "Cooperative") [ set opponentchoice 1 ] if (opponent-strategy = "Conflictual") [ set opponentchoice 0 ] if (opponent-strategy = "Random") [ let randomchoice random 1000 ifelse (randomchoice < 500) [ set opponentchoice 0 ] [ set opponentchoice 1 ] ] if (opponent-strategy = "Reciprocation") [ ifelse (iteration = 1) [ set opponentchoice initial-play ] [ set opponentchoice playerchoice ] ] set playerchoice 0 if (your-strategy = "Cooperate (up)") [ set playerchoice 1 ] if (your-strategy = "Reciprocation") [ ifelse (iteration = 1) [ set playerchoice initial-play ] [ set playerchoice opponentchoice ] ] ] [ if (unknown-strategy = "Cooperative") [ set opponentchoice 1 ] if (unknown-strategy = "Conflictual") [ set opponentchoice 0 ] if (unknown-strategy = "Random") [ let randomchoice random 1000 ifelse (randomchoice < 500) [ set opponentchoice 0 ] [ set opponentchoice 1 ] ] if (unknown-strategy = "Reciprocation") [ ifelse (iteration = 1) [ set opponentchoice initial-play ] [ set opponentchoice playerchoice ] ] set playerchoice 0 if (your-strategy = "Cooperate (up)") [ set playerchoice 1 ] if (your-strategy = "Reciprocation") [ ifelse (iteration = 1) [ set playerchoice initial-play ] [ set playerchoice opponentchoice ] ] ] ;; Find player 2 strategy set iteration iteration + 1 set game-outcome (word playerchoice ", " opponentchoice) end to calculate-payoffs if (game = "Rules of the Road") [ if (game-outcome = "0, 0") [ set player-score player-score + 1 set opponent-score opponent-score + 1 ] if (game-outcome = "1, 0") [ set player-score player-score + 0 set opponent-score opponent-score + 0 ] if (game-outcome = "0, 1") [ set player-score player-score + 0 set opponent-score opponent-score + 0 ] if (game-outcome = "1, 1") [ set player-score player-score + 1 set opponent-score opponent-score + 1 ] ] if (game = "Vacation") [ if (game-outcome = "0, 0") [ set player-score player-score + 1 set opponent-score opponent-score + 2 ] if (game-outcome = "1, 0") [ set player-score player-score set opponent-score opponent-score ] if (game-outcome = "0, 1") [ set player-score player-score set opponent-score opponent-score ] if (game-outcome = "1, 1") [ set player-score player-score + 2 set opponent-score opponent-score + 1 ] ] if (game = "Prisoner's Dilemma") [ if (game-outcome = "0, 0") [ set player-score player-score + 1 set opponent-score opponent-score + 1 ] if (game-outcome = "1, 0") [ set player-score player-score + 0 set opponent-score opponent-score + 3 ] if (game-outcome = "0, 1") [ set player-score player-score + 3 set opponent-score opponent-score + 0 ] if (game-outcome = "1, 1") [ set player-score player-score + 2 set opponent-score opponent-score + 2 ] ] end to plot-results end ;;; SETUP STUFF to draw-lines create-turtles 1 [ set color white setxy -8 8 set heading 90 pd forward 16 set heading 180 forward 16 set heading 270 forward 16 set heading 0 forward 16 die ] create-turtles 1 [ set color white setxy -8 0 set heading 90 pd fd 16 pu setxy 0 -8 set heading 0 pd fd 16 die ] end to make-labels if game = "Rules of the Road" [ ask turtle 0 [ set label "Crash, Crash" ] ask turtle 1 [ set label "Alive, Alive" ] ask turtle 2 [ set label "Crash, Crash"] ask turtle 3 [ set label "Alive, Alive"] ] if game = "Vacation" [ ask turtle 0 [ set label "Alone, Alone" ] ask turtle 1 [ set label "Disapp, Happy" ] ask turtle 2 [ set label "Alone, Alone"] ask turtle 3 [ set label "Happy, Disapp"] ] if game = "Prisoner's Dilemma" [ ask turtle 0 [ set label "3 Yrs, Free" ] ask turtle 1 [ set label "2 Yrs, 2 Yrs" ] ask turtle 2 [ set label "Free, 3 Yrs"] ask turtle 3 [ set label "1 Yr, 1 Yr"] ] end to generate-titles create-titles 1 [ set color black setxy -9 0 set label "you" ] create-titles 1 [ set color black setxy 1 9 set label "opponent" ] end to generate-opponent create-opponents 1 [ set hidden? true ] end to setup-scores set unknown-strategy 0 set player-score 0 set opponent-score 0 set game-outcome "null" set initial-play 0 set iteration 1 if (opponent-strategy = "Unknown") [ set unknown-strategy one-of [ "Cooperative" "Conflictual" "Reciprocation" "Random" ]] end

There are 8 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Game Theory UHON 111 SP24.png | preview | Preview for 'Game Theory UHON 111 SP24' | 8 months ago, by David Earnest | Download |

This model does not have any ancestors.

This model does not have any descendants.