Civilization
Model was written in NetLogo 5.0.5
•
Viewed 568 times
•
Downloaded 41 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
;; note : ;; cycle jour/nuit avec green + + et - - ;; chasse mais avec les arbres pour le bois ;; creation denfants, vieillissement ;; fd en fonction de lage Breed [humans Human] breed [tree wood] breed [towns town] breed [foods food] breed [houses house] directed-link-breed [hunters hunter] directed-link-breed [parents parent] undirected-link-breed [lovers love] tree-own [ ressource ] towns-own [ stock-food stock-wood ] humans-own [ sexe age metier energie energie-max max-transporte type-item quantity target my-home can_move? ] houses-own[ owner ] foods-own [ ressource energie can_move?] globals [ year day hour night? mort-vieu mort-number ] to SETUP ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) __clear-all-and-reset-ticks prepare-patch prepare-turtle set year 0 set hour 10 set night? false set mort-number 0 set mort-vieu 0 end to prepare-turtle ask n-of 1 patches WITH [pxcor < 70 and pxcor > -70 and pycor < 70 and pycor > -70 ][ sprout 1[ set breed towns set shape "campsite" set size 5 set color 52 set stock-food 10000 ] create_human humans-quantity 20 ] create_tree 500 create_food 1000 end to prepare-patch ask patches[ set pcolor green ] end to affichage ifelse show-couple? [ask lovers [show-link]][ask lovers [hide-link]] ifelse show-hunters? [ask hunters [show-link]][ask hunters [hide-link]] ifelse show-generation? [ask parents [show-link]][ask parents [hide-link]] end to graph set-current-plot "Population" set-current-plot-pen "total" plot (count humans) set-current-plot-pen "couples" plot (count lovers) set-current-plot "Mort" set-current-plot-pen "Total" plot (mort-number) set-current-plot-pen "Vieillesse" plot (mort-vieu) set-current-plot "Ressources" set-current-plot-pen "Stock" plot (sum [stock-food] of towns) set-current-plot-pen "Nature" plot (sum [ressource] of foods) set-current-plot "Population Age" set-current-plot-pen "Age_moyen" plot (sum [age] of humans / count humans) set-current-plot-pen "Esperance de vie" plot (sum [energie-max] of humans / count humans) end to GO affichage ifelse less-lag? [ ask turtles with [ breed != humans and breed != houses and breed != towns ] [ hide-turtle] ][ask turtles [show-turtle]] every Speed[ go-town if not night? [ take-target hunt relationship create-family ] move repop mort if test-fast? [naissance] if night? [ naissance ask humans [ set target nobody ask my-out-hunters [die] ] ] ] every (Speed + 0.1) * 1.2[ graph set hour hour + (2 / 30) if test-fast? [ ask humans [if (not night?) or (night? and age < 20) [ set age age + 0.5]]] if night? [set hour hour + 1 / 30] if hour > 24 [ set hour 0 set day day + 1 if not test-fast? [ask humans[ set age age + 2]]] if day > 365 [ set day 0 set year year + 1] set night? false if hour < 9 [set night? true] if hour < 9 and hour > 7[ ask patches with [pcolor < 55][ set pcolor pcolor + 0.3 ]] if hour > 19[ set night? true ask patches with [pcolor > 53][ set pcolor pcolor - 0.3 ]] ask humans [ set size age / 100 if size > 2 [set size 2 ]] ] if count humans = 0 [ stop ] end to mort ask turtles With [(breed = humans) or (breed = foods)][ if energie < 0 [ if breed = humans [ set mort-number mort-number + 1] die ] ] ask humans [ ;; if age > ( random 20 + 85 ) [die] if (age > (energie-max / 5 ) and not test-fast?) or (age > ( energie-max) and test-fast? ) [ set mort-number mort-number + 1 set mort-vieu mort-vieu + 1 die] ] ask hunters [ ask end1 [ set target nobody ] if link-length > 10 or end2 = nobody or end1 = nobody [die] ] ask houses[ if owner != nobody [ if count owner = 0 [die] ] ] end to move ask turtles With [((breed = humans) or (breed = foods)) and can_move?][ if random 100 < 30 [ left random 90 right random 90 ] if breed = foods and random 1000 < 10 [ face min-one-of towns [distance myself] ] if breed = humans [ let close-town my-home if target != nobody[ face target ] if ([distance myself] of close-town >= ( (energie - (60 / 100 * energie)) / 2 - 10 / 100 * energie)) or (quantity > max-transporte) or night? [ face close-town ] fd 0.5 ] if (breed = humans or (breed = foods and not night?)) [fd 0.2 ] if not night? [set energie energie - 1] ] end to repop if (random 1000 < 50) and (count tree < 600) [ create_tree 3 if night? [create_tree 7] ] if (random 1000 < 50) and (count foods < 600) [ create_food 7 if not night? [create_food 3] ] end to create_tree [ number ] ask n-of (random number) patches[ sprout 1 [ set breed tree set shape "tree" set color green - 2 set ressource random 100 set size (ressource / 10) ] ] end to create_human [number value-age] sprout number [ set breed humans set shape "person" set size 1.1 ifelse random 100 > 50 [set color red set sexe "male"] [set color blue set sexe "female"] set age ((random value-age) + 17 ) ifelse test-fast? [set energie-max ((random (( hour + 2 + day * 24 ) * 100)) + 100)][ set energie-max ((random (( day + 2 ) * 100)) + 100)] set energie random energie-max + energie-max set max-transporte 1000 set type-item "" set quantity 0 set target nobody set my-home min-one-of towns [distance myself] set can_move? true ] end to create_food [number] ask n-of (random number) patches[ sprout 1 [ set breed foods set shape "cow" set ressource random 1000 + 800 set size ressource / 700 set energie 5000 set color white set can_move? true ] ] end to create_house hatch 1 [ set color random 100 set breed houses set shape "house efficiency" set size 2 set owner nobody ] end to go-town let terrain nobody ask towns [ set size ( count humans in-radius 100 ) / 50 ] ask houses[ set owner (humans with [ my-home = myself]) set size count owner ] ask humans[ if [distance myself] of my-home < 3 [ let dechargement quantity let temp-type type-item let consommation-food energie-max - energie let regeneration 0 ask min-one-of towns [distance myself] [ if temp-type = foods and stock-food < count humans * 1000 [ set stock-food stock-food + dechargement ] if temp-type = tree and stock-wood < count humans * 100 [ set stock-wood stock-wood + dechargement ] ifelse consommation-food > stock-food [set regeneration stock-food] [set regeneration consommation-food] set stock-food stock-food - regeneration ] set quantity 0 set energie energie + regeneration ] ] end to hunt ask humans with [(target != nobody)] [ if target != nobody and [distance myself] of target < 1[ move-to target if target != nobody and [breed] of target = foods [ ajout-transport ([ressource] of target) ask target [die] ] if target != nobody and [breed] of target = tree [ ajout-transport 10 ask target [set ressource ressource - 10 set size (ressource / 10) if ressource < 0 [die]]] ] ] end to ajout-transport [ value ] ifelse quantity + value < max-transporte [ set quantity quantity + value ][ set quantity max-transporte] end to take-target ask humans with [quantity < max-transporte and age > 18] [ let temp-target [] ifelse type-item = "" and (count humans with [type-item = foods] / count humans * 100) < 50 [set temp-target (turtle-set foods in-radius 5) ][ ifelse type-item = "" and (count humans with [type-item = tree] / count humans * 100) < 50 [set temp-target (turtle-set tree in-radius 15) ] [ let temp-breed type-item set temp-target turtles in-radius 10 with [breed = temp-breed] ]] set temp-target temp-target with [count my-in-hunters < 5] set temp-target min-one-of temp-target [distance myself] if temp-target != nobody[ ask hunters with [end1 = myself] [die] set target temp-target create-hunter-to target [set color red ifelse show-hunters? [show-link][hide-link]] set type-item [breed] of target ] ] end to relationship ask humans[ if age > (random 6 + 17) and random 100 < 5 and count my-lovers = 0 [ let my-sexe sexe let my-age age let my-place my-home let possible-love humans with [distance myself < 5 and sexe != my-sexe and age > (random 6 + 17) and age > my-age - 20 and age < my-age + 20 and (my-home != my-place or [breed] of my-home = towns or [breed] of my-place = towns) and count my-lovers = 0 ] if count possible-love != 0[ set possible-love min-one-of possible-love [distance myself] create-love-with possible-love [set color pink ifelse show-couple? [show-link][hide-link]] let couple [] ask my-lovers [ set couple both-ends ] ask couple [ set my-home min-one-of towns [distance myself] ]]]] end to create-family ask humans [ if random 100 < 5 and count my-lovers != 0 and count houses in-radius 10 = 0 and count towns in-radius 5 = 0 [ let family [] let person1 nobody let person2 nobody ask my-lovers [ set family both-ends set person1 end1 set person2 end2 ] let breed1 0 let breed2 0 ask person1 [ set breed1 [breed] of my-home] ask person2 [ set breed2 [breed] of my-home] if (breed1 != breed2 or breed1 = towns or breed2 = towns) [ create_house let new-house one-of houses-here ask family[ set my-home new-house ]] ] ] end to naissance ;; ask humans with [(count my-lovers != 0) and (count my-out-parents < 10) and (sexe = "female") and ([breed] of my-home = houses)][ ask humans with [(count my-lovers != 0) and (sexe = "female") and ([breed] of my-home = houses)][ if random 1000 < 5 [ let parent [] let parent1 nobody let parent2 nobody ask my-lovers [ set parent both-ends set parent1 end1 set parent2 end2 ] let energie-average (( [energie-max] of parent1 + [energie-max] of parent1 ) / 2) ;; print (word "parent1 : " parent1 ", parent2 : " parent2 ", average : " energie-average) hatch 1[ ifelse random 100 > 50 [set color red set sexe "male"] [set color blue set sexe "female"] set age 0 ifelse test-fast? [ set energie-max ( random energie-average * 2 ) + ( hour + day * 24) * 5 + ( energie-average )][ set energie-max ( random energie-average * 2 ) + ( day * 5 ) + ( energie-average )] set energie random energie-max + energie-max / 2 set type-item "" set quantity 0 set target nobody set can_move? true create-parents-from parent [set color yellow ifelse show-generation? [show-link][hide-link]] ] ]] end
There is only one version of this model, created over 10 years ago by Leo B.
This model does not have any ancestors.
This model does not have any descendants.