Yu_Liu_FinalProject_V1

No preview image

1 collaborator

Img_3637 Yu Liu (Author)

Tags

sociology 

Tagged by Yu Liu over 12 years ago

Part of project 'Yu_Liu_FinalProject'
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.4 • Viewed 662 times • Downloaded 39 times • Run 0 times
Download the 'Yu_Liu_FinalProject_V1' modelDownload this modelEmbed this model

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


Rules

All people come to Western with 100 dollars. If I am a gold-digger: If I have money to detect and dig, I detect whether there is treasure underground. If I find there is treasure, I dig it out to become richer Then I move to other place if I have money to travel

If I am a cowboy: I first grab money from gold-digger if there is any here Then move to another place if I have money to travel

The system stop in two conditions:

  1. No treasure under ground.
  2. All gold diggers have no money.

WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

Comments and Questions

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

Click to Run Model

globals [number-of-digged total]
patches-own [treasure? resource]

breed [gold-digger a-gold-digger]
breed [cowboy a-cowboy]
breed [sheriff a-sheriff]
turtles-own[money]

to setup
  ca
  set total 0
  ask patches[
  ;  set pcolor brown
    ifelse (random-float 100.0) < treasure-ratio          ;;some place have treasure under ground
    [set treasure? true
      set total total + 1]
    [set treasure? false]
  ]

  create-gold-digger number-of-gold-digger[
    set size 2;
    set money 100
    set shape "person"
    set color green                                      ;;gold-digger is green
    setxy random-xcor random-ycor
  ]
  create-cowboy number-of-cowboy[
    set size 2;
    set money 100
    set shape "person"
    set color red                                        ;;cowboy is red
    setxy random-xcor random-ycor
  ]
  create-sheriff number-of-sheriff[
    set size 2;
    set money 100
    set shape "person"
    set color yellow                                        
    setxy random-xcor random-ycor
  ]
  set number-of-digged 0
  recolor-resource
  reset-ticks
end 

to go
  if number-of-digged = total                            ;;is all treasure all digged out
  [stop]
  if sum [money] of gold-digger = 0
  [stop]
  if number-of-cowboy = 0                                ;;the society is finally stable
  [stop]  
  ask turtles[
    search
  ]
  ask gold-digger[   
    dig                                                  ;;gold digger will dig treasure first then search other place
  ]
  ask cowboy[
    grab-money                                           ;;cowboy will grab money from gold-digger then search others
  ]
  ask sheriff[
    punish-cowboy
  ]
  recolor-resource
  tick
end 

to search
  if money > 0                                           ;;move to other place, it costs 1 dollar
  [rt random 90
  lt random 90
  fd 1
  set money money - 1]
end 

to dig
  if money > detect-cost + dig-cost
  [set money money - detect-cost                             ;;dig treasure but cost some money
  if treasure?                                           ;if there is treasure here
  [   set money money - dig-cost                          
      set treasure? false
      set money money + 100
      set number-of-digged number-of-digged + 1]  ]     ;;record how many treasure are discovered
end 

to grab-money
  let money-from 0
  if any? gold-digger-here [  ;; if there are gold-digger then grab money
    ask one-of gold-digger-here[
      set money-from money                              ;;record how many money can grab
      set money 0
      digger-killed
      ]
    set money money + money-from                        ;;add this money to cowboy's money
  ]
end 

to punish-cowboy
  let money-from 0
  if any? cowboy-here [  ;; if there are gold-digger then grab money
    ask one-of cowboy-here[
      set money-from money                              ;;record how many money can punish
      set money 0
      cowboy-killed
      ]
    set money money + money-from                        ;;add this money to cowboy's money
  ]
end 

to digger-killed
  if (random-float 100) < cowboy-kill-digger-chance
  [die]
end 

to cowboy-killed
  if (random-float 100) < sheriff-kill-cowboy-chance
  [die]
end 


;; recolor the resource to indicate how much has been eaten

to recolor-resource
  ask patches with [treasure? = false]
  [
    set pcolor black
  ]
  ask patches with [treasure? = true]
  [
    set pcolor brown
  ]
end 

to-report total-money-of-gold-digger                    ;;report all money of gold-digger
 report sum [money] of gold-digger
end 

to-report total-money-of-cowboy                         ;;report all money of cowboy
 report sum [money] of cowboy
end 

to-report total-money-of-sheriff                         ;;report all money of cowboy
 report sum [money] of sheriff
end 

There is only one version of this model, created over 12 years ago by Yu Liu.

Attached files

File Type Description Last updated
YuLiu_May13.docx word Progress report over 12 years ago, by Yu Liu Download

This model does not have any ancestors.

This model does not have any descendants.