Parrondo on a network
Model was written in NetLogo 6.2.1
•
Viewed 261 times
•
Downloaded 17 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;; ;; internal variables for agents ;; turtles-own [ state ;; current state, 1 - winning, 0 - loosing state-1 ;; state in the previous round, 1 - winning, 0 - loosing wealth ;; total wealth, set to some initial value during the setup ] ;; ;; setup the world: creat agents, assign states ;; to setup clear-all ask patches [ set pcolor white sprout 1 [ set wealth intial-wealth set shape "person" ifelse random-float 1 < 0.5 [ set state 1 ][ set state 0 ] ifelse random-float 1 < 0.5 [ set state-1 1 ][ set state-1 0 ] ] ] reset-ticks end ;; ;; main process ;; to go ask one-of turtles [ ;; position swapping process if random-float 1.0 > swap-prob [ swap-postions ] ;; include more colors and id show-debug-info ;; ;; main switch based on the type of selected game ;; ifelse random-float 1.0 < gameA-prob [ zero-sum-game ;; game A ][ ( ifelse gameB-type = "capital-based" [ capital-based-game ] gameB-type = "niche-based" [ niche-based-game ] gameB-type = "state-based" [ state-based-game ] gameB-type = "new-type-example" [ new-type-game ] ) ] ] tick end ;; ;; exchange postion with one of neighbours ;; to swap-postions let goal one-of neighbors let here patch-here ;; migrate from the goal ask turtles-on goal [ ;;set pcolor blue move-to here show-debug-info ] ;; move to the goal move-to goal end ;; ;; display some debug information ;; to show-debug-info if debug [ show who set color black set label who ifelse state = "winner" [ set pcolor green ][ set pcolor red ] ] end ;; ;; ;; to warn-unimplemented if who = 0 [ show "[Warning] This function is not implemented yet!" ] end ;; ;; implementation of elementary games used in the schemes ;; ;; ;; game A - zero-sum game played with probability ;; to zero-sum-game ifelse random-float 1.0 < 0.5 [ set state 1 set wealth wealth + 1 ask turtles-on one-of neighbors [ set state 0 set wealth wealth - 1 ] ][ set state 0 set wealth wealth - 1 ask turtles-on one-of neighbors [ set state 1 set wealth wealth + 1 ] ] end ;; ;; standard verion of Parronod's scheme, based on the accumulated wealth ;; to capital-based-game ;; local variable for controlling elementary game let pWin -1 ;; check the condition based on divisibility and set the probability ifelse wealth mod bigM = 0 [ set pWin pWinBranch1 ][ set pWin pWinBranch2 ] ;; play with p assigned to the apropriate branch ifelse random-float 1.0 < pWin [ set state 1 set wealth wealth + 1 ][ set state 0 set wealth wealth - 1 ] end ;; ;; ;; to state-based-game ;; set the probabilities for all cases let probsWinState (list pWinState00 pWinState01 pWinState10 pWinState11 ) ;; save the current state in the history set state-1 state ;; update the state and the wealth ifelse ( random-float 1.0 ) < ( item (2 * state + state-1) probsWinState ) [ set state 1 set wealth wealth + 1 ][ set state 0 set wealth wealth - 1 ] end ;; ;; ;; to niche-based-game ;; set the probabilities for all cases let probsWinNiche (list pWinNiche0 pWinNiche1 pWinNiche2 pWinNiche3 pWinNiche4 ) ;; read the states of agents in the von Neumann neighborhood let whichBranch sum [state] of turtles-on neighbors4 ;; save the current state in the history set state-1 state ;; update the state and the wealth ifelse ( random-float 1.0 ) < ( item whichBranch probsWinNiche ) [ set state 1 set wealth wealth + 1 ][ set state 0 set wealth wealth - 1 ] end ;; ;; example of procedure implementing new game B ;; to new-type-game warn-unimplemented end ;; ;; ;; to-report mean-state report mean [state] of turtles end ;; ;; ;; to-report mean-wealth-change report ( mean [wealth] of turtles ) - intial-wealth end to-report mean-wealth-change-zero report ( [wealth] of turtle 0 ) - intial-wealth end
There is only one version of this model, created over 2 years ago by Jaroslaw Miszczak.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Parrondo on a network.png | preview | Preview for 'Parrondo on a network' | over 2 years ago, by Jaroslaw Miszczak | Download |
This model does not have any ancestors.
This model does not have any descendants.