Yu_Liu_FinalProject_V1
No preview image
Model was written in NetLogo 5.0.4
•
Viewed 416 times
•
Downloaded 22 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
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 11 years ago by Yu Liu.
This model does not have any ancestors.
This model does not have any descendants.