# Miner's Dillema Iterated

Model was written in NetLogo 6.2.0
•
Viewed 31 times
•
Downloaded 0 times
•
Run 0 times

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

## WHAT IS IT?

This model of miner's dilemma is based on a simple two-person iterated prisoner's dilemma (Wilensky, 2002). Can you improve the strategies?

- Wilensky, U. (2002). NetLogo PD Two Person Iterated model. http://ccl.northwestern.edu/netlogo/models/PDTwoPersonIterated. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

## Comments and Questions

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

Click to Run Model

breed [poolAs poolA] breed [poolBs poolB] globals [ hidden-strategy gM ; global miners ] turtles-own [ profit x ; infiltrating miners m ; honest miners R ; pool reward (as it seems) hR ; reward from honest mining xR ; reward from infiltration infiltrate-now? partner ; the other pool agent partner-infiltrated? partner-infiltrated-past? ] to setup clear-all set-default-shape poolAs "computer" set-default-shape poolBs "computer" create-poolAs 1 [ set heading 90 fd max-pxcor / 2 ] create-poolBs 1 [ set heading 270 fd max-pxcor / 2 ] ask poolAs [ set m m1 set x int (m / 10) ; set infiltrators as m/10 and integerize ] ask poolBs [ set m m2 set x int (m / 10) ; set infiltrators as m/10 and integerize ] set gM (oM + m1 + m2) ask turtles [ set size 10 set partner one-of other turtles set infiltrate-now? false set partner-infiltrated? false set partner-infiltrated-past? false run "set-properties" ] set hidden-strategy one-of [ "act-randomly" "always-honest" "always-infiltrate" "tit-for-tat" "tit-for-two-tats" "unforgiving" "custom-strategy" ] reset-ticks ;prepare-next-round end ;;;;;;;;;;;;;;;;;; ;;; Play game ;;; ;;;;;;;;;;;;;;;;;; to play play-a-round tick ;prepare-next-round end to play-a-round ask turtles [ run "set-properties" ] ask poolAs [ run poolA-strategy ] ; run strategies ifelse select-poolB-strategy? [ ask poolBs [ run poolB-strategy ] ] [ ask poolBs [ run hidden-strategy ] ] ; determine this round's payoffs based on the action each agent has chosen ask turtles [ get-payoff ] end to prepare-next-round ask turtles [ set label average-profit ] end to-report average-profit ; Turtle reporter report precision (profit / ticks) 3 end to-report relative-profit report profit / [profit] of partner end ;;;;;;;;;;;;;;;;;; ;;; Properties ;;; ;;;;;;;;;;;;;;;;;; to set-properties set R ((m - x) / (gM - x - ([x] of partner))) set xR x * [R] of partner /([m] of partner - [x] of partner + x) set hR (m - x) * R / (m - x + [x] of partner) set profit xR + hR end ;;;;;;;;;;;;;;;;;; ;;; Strategies ;;; ;;;;;;;;;;;;;;;;;; to act-randomly ; Turtle Procedure set infiltrate-now? one-of [ true false ] end to always-honest ; Turtle Procedure set infiltrate-now? false end to always-infiltrate ; Turtle Procedure set infiltrate-now? true end to tit-for-tat ; Turtle Procedure ifelse partner-infiltrated? [ set infiltrate-now? true ] [ set infiltrate-now? false ] end to tit-for-two-tats ; Turtle Procedure ifelse partner-infiltrated? and partner-infiltrated-past? [ set infiltrate-now? true ] [ set infiltrate-now? false ] end to unforgiving ; Turtle Procedure ifelse partner-infiltrated? or infiltrate-now? [ set infiltrate-now? true ] [ set infiltrate-now? false ] end to custom-strategy ; Turtle Procedure ; Currently defaults to tit-for-tat. Can you do better? ifelse partner-infiltrated? ; partner infiltrateded stores your partner's action last round [ set infiltrate-now? true ] [ set infiltrate-now? false ] end ;;;;;;;;;;;;;;;;;;;;;; ;;; End Strategies ;;; ;;;;;;;;;;;;;;;;;;;;;; to get-payoff ; Turtle Procedure set partner-infiltrated-past? partner-infiltrated? set partner-infiltrated? [ infiltrate-now? ] of partner ifelse partner-infiltrated? [ ifelse infiltrate-now? [ if x < m - 1 [set x x + 1] ] [ if x > 0 [set x x - 1] ] ] [ ifelse infiltrate-now? [ if x < m - 1 [set x x + 1] ] [ if x > 0 [set x x - 1] ] ] end

There is only one version of this model, created about 1 month ago by Spicy Corn.

## Attached files

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

Miner's Dillema Iterated.png | preview | Preview for 'Miner's Dillema Iterated' | about 1 month ago, by Spicy Corn | Download |

This model does not have any ancestors.

This model does not have any descendants.