-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRome_Empire_Simulation.nlogox
More file actions
1580 lines (1459 loc) · 60.7 KB
/
Rome_Empire_Simulation.nlogox
File metadata and controls
1580 lines (1459 loc) · 60.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<model version="NetLogo 7.0.2" snapToGrid="true">
<code><![CDATA[;;;;;;;;;;;;;;;;;
;;; BREEDS ;;;;;;
;;;;;;;;;;;;;;;;;
breed [ settlements settlement ]
breed [ traders trader ]
;;;;;;;;;;;;;;;;;
;;; VARIABLES ;;;
;;;;;;;;;;;;;;;;;
globals [
routes
;; imperial-stability (Slider 0-100)
legion-strength
political-influence
;; Internal logic variables
smoothIterations
coastLineSmoothThreshold
relativePathCostInLand
portTechVariation
]
settlements-own [
sizeLevel
currentNumberOfTraders
potentialNumberOfTraders
stock
culturalVector
fortification-level
]
traders-own [
isActivated
base
route
destination
direction
lastPosition
cargoValue
culturalSample
legionAttached?
]
patches-own [
isLand
pathCost
parent-patch
f
g
h
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; SETUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to rome-setup
clear-all
;; Internal settings
set smoothIterations 2
set coastLineSmoothThreshold 4
set relativePathCostInLand 5
set portTechVariation 10
reset-ticks
random-seed seed
rome-create-map
rome-create-coastal-settlements
print "Calculating maritime trade routes (A*)..."
rome-set-routes
print "Routes established."
rome-create-traders-per-settlement
;; Force an initial display update
rome-update-display
end
to rome-create-map
let cx 0
let cy 0
if (min-pxcor > 0 or min-pycor > 0) [
set cx round (min-pxcor + max-pxcor) / 2
set cy round (min-pycor + max-pycor) / 2
]
let halfSmallerDimension (world-width / 2)
if (world-width > world-height) [ set halfSmallerDimension (world-height / 2) ]
let minDistOfLandToCenter ((pondSize / 100) * halfSmallerDimension)
let noiseRange (halfSmallerDimension * coastalNoiseLevel / 100)
ask patches [
let coastThreshold minDistOfLandToCenter
if (noiseType = "uniform") [
set coastThreshold minDistOfLandToCenter + (random-float noiseRange) - (noiseRange / 2)
]
if (noiseType = "normal") [
set coastThreshold random-normal minDistOfLandToCenter (noiseRange / 4)
]
ifelse (distancexy cx cy < coastThreshold)
[ set isLand false ]
[ set isLand true ]
rome-paint-terrain
]
rome-smooth-coast-line
rome-assign-path-cost
end
to rome-smooth-coast-line
repeat smoothIterations [
ask patches [
let landNeighbors count neighbors with [isLand = true]
let waterNeighbors count neighbors with [isLand = false]
let totalNeighbors count neighbors
ifelse (isLand = false) [
if (landNeighbors / totalNeighbors >= coastLineSmoothThreshold / 8) [
set isLand true
]
][
if (waterNeighbors / totalNeighbors >= coastLineSmoothThreshold / 8) [
set isLand false
]
]
rome-paint-terrain
]
]
end
to rome-assign-path-cost
ask patches [
ifelse (isLand = false)
[ set pathCost 1 ]
[ set pathCost relativePathCostInLand ]
]
end
to rome-paint-terrain
ifelse (isLand = false)
[ set pcolor 106 ] ;; Blue
[ set pcolor 54 ] ;; Brownish-Green
end
to rome-create-coastal-settlements
let coastalPatches patches with [(isLand = true) and (any? neighbors with [isLand = false])]
repeat numberOfSettlements [
if any? coastalPatches with [not any? settlements-here] [
ask one-of coastalPatches with [not any? settlements-here] [
sprout-settlements 1 [
set sizeLevel 1
set stock 50
set culturalVector rome-extract-rgb color
set culturalVector lput (random-normal 0 landTechVariation) culturalVector
set culturalVector lput (random-normal 0 portTechVariation) culturalVector
set culturalVector lput (random-float maxSettlementSizeDecayRate) culturalVector
set culturalVector lput (random-float maxStockDecayRate) culturalVector
set culturalVector lput (random-float maxProductionRate) culturalVector
set culturalVector lput (random-float 1) culturalVector
set culturalVector lput (random-float maxTraitTransmissionRate) culturalVector
set culturalVector lput (random-float maxMutationVariation) culturalVector
set fortification-level random 10
set shape "circle 2"
set size 2
]
set pathCost relativePathCostInPort
]
]
]
end
to rome-create-traders-per-settlement
ask settlements [
let thisSettlement self
set potentialNumberOfTraders rome-get-potential-number-of-traders
hatch-traders potentialNumberOfTraders [
rome-setup-trader thisSettlement
]
set currentNumberOfTraders rome-get-current-number-of-traders
]
end
to rome-setup-trader [ baseSettlement ]
set base baseSettlement
set isActivated true
set shape "default"
set color [color] of base
set size 1.5
set legionAttached? false
rome-choose-destination
end
to rome-set-routes
set routes []
let settlementsList sort settlements
let n length settlementsList
let i 0
while [i < n] [
let j i + 1
while [j < n] [
let s1 item i settlementsList
let s2 item j settlementsList
;; Call A* Pathfinder
let optimalRoute rome-find-a-path ([patch-here] of s1) ([patch-here] of s2)
if not empty? optimalRoute [
set routes lput optimalRoute routes
]
set j j + 1
]
set i i + 1
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; CYCLE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to rome-go
rome-update-settlements
if not any? traders [ stop ]
rome-update-traders
;; --- TURBO MODE ---
;; Only update the screen (map + plot) every 50 ticks to speed up calculation
if ticks mod 50 = 0 [
rome-update-display
]
tick
;; No tick limit (Infinite run)
end
to rome-update-traders
let activeTraders traders with [isActivated]
ask activeTraders [
;; A* Position check
if is-list? route and member? patch-here route [
set lastPosition patch-here
]
if rome-is-in-base or rome-is-in-destination [
;; LOGIC: Unload handles both Trade and War
if cargoValue > 0 [ rome-unload-cargo ]
if rome-is-in-base and ([potentialNumberOfTraders < currentNumberOfTraders] of base) [
set isActivated false
ask base [ set currentNumberOfTraders rome-get-current-number-of-traders ]
]
if isActivated [
rome-load-cargo
if cargoValue > 0 [
rome-choose-destination
rome-find-direction
]
]
]
if isActivated [
rome-move-to-destination
]
]
end
to rome-choose-destination
let thisTrader self
let possibleRoutes rome-get-routes-to-settlement [base] of thisTrader
if not empty? possibleRoutes [
set possibleRoutes sort-by [ [r1 r2] ->
rome-benefit-cost-of-route r1 thisTrader > rome-benefit-cost-of-route r2 thisTrader
] possibleRoutes
set route first possibleRoutes
let endpoints (rome-get-origin-and-destination route)
set destination one-of endpoints with [self != [base] of thisTrader]
]
end
to rome-find-direction
if not is-list? route or empty? route [ stop ]
let currentPos position lastPosition route
if currentPos = false [ stop ]
ifelse (currentPos = 0)
[ set direction 1 ]
[ if (currentPos = (length route - 1)) [ set direction -1 ] ]
end
to rome-move-to-destination
if not is-list? route or empty? route [ stop ]
if position lastPosition route = false [
set lastPosition min-one-of (patch-set route) [distance myself]
]
let currentPos position lastPosition route
if currentPos = false [ stop ]
let targetIdx currentPos + direction
if targetIdx < 0 or targetIdx >= length route [ stop ]
let target item targetIdx route
facexy ([pxcor] of target) ([pycor] of target)
let step-size 0.5
let dist distancexy ([pxcor] of target) ([pycor] of target)
forward min (list step-size dist)
end
to-report rome-is-in-base
report distance base < 1.0
end
to-report rome-is-in-destination
ifelse destination = nobody [ report false ] [ report distance destination < 1.0 ]
end
;; --- WAR & TRADE LOGIC ---
to rome-unload-cargo
let settlementHere one-of settlements-here
if settlementHere != nobody [
;; 1. Calculate Cultural Difference
let myCulture (sublist [culturalVector] of base 0 3)
let theirCulture (sublist [culturalVector] of settlementHere 0 3)
let culturalDist distance-between-vectors myCulture theirCulture
;; 2. Determine Threshold based on Stability Slider
let tolerance (imperial-stability * 4)
ifelse (culturalDist > tolerance) [
;; WAR: Raid behavior
ask settlementHere [ rome-raid-settlement myself ]
set cargoValue 0
] [
;; PEACE: Trade behavior
ask settlementHere [ rome-add-trade-effect myself ]
set cargoValue 0
]
]
end
;; --- THE "NO MERCY" RAID UPDATE ---
to rome-raid-settlement [ invader ]
;; Visual Feedback: Flash Red
set color red
;; NUCLEAR LOGIC: No Defense. Pure Damage.
let attackStrength ([cargoValue] of invader)
;; 1. Walls crumble instantly
if fortification-level > 0 [ set fortification-level 0 ]
;; 2. Damage is raw and unmitigated (1:1 Ratio)
;; If Trader has 100 cargo, City loses 100 Size immediately.
let damage attackStrength
if damage > 0 [
;; Steal Stock
set stock max (list 0 (stock - damage))
;; Kill Population (Fast Decay)
set sizeLevel max (list 1 (sizeLevel - damage))
]
end
to-report distance-between-vectors [ v1 v2 ]
let sum-sq 0
let i 0
foreach v1 [ [x] ->
let y item i v2
set sum-sq sum-sq + ((x - y) ^ 2)
set i i + 1
]
report sqrt sum-sq
end
;; --- END WAR LOGIC ---
to rome-load-cargo
let settlementHere one-of settlements-here
if settlementHere != nobody [
set cargoValue [stock] of settlementHere
ask settlementHere [ set stock 0 ]
set culturalSample [culturalVector] of settlementHere
]
end
to rome-update-settlements
ask settlements [
;; Decay and Production
set sizeLevel max (list 1 (sizeLevel * (1 - ((item 5 culturalVector) / 100)) ) )
set stock (stock * (1 - ((item 6 culturalVector) / 100))) + (sizeLevel * ((item 7 culturalVector) / 100))
set potentialNumberOfTraders rome-get-potential-number-of-traders
set currentNumberOfTraders rome-get-current-number-of-traders
;; Spawn new traders logic
if (currentNumberOfTraders < potentialNumberOfTraders and random-float 1 < 0.1) [
hatch-traders 1 [ rome-setup-trader myself ]
set currentNumberOfTraders currentNumberOfTraders + 1
]
rome-mutate-traits
]
end
to rome-add-trade-effect [ aTrader ]
let incomingSample [culturalSample] of aTrader
let transmissionRate ((item 9 culturalVector) / 100)
let newVector []
let i 0
foreach culturalVector [ [trait] ->
let otherTrait item i incomingSample
let change (otherTrait - trait) * transmissionRate
set newVector lput (trait + change) newVector
set i i + 1
]
set culturalVector newVector
set sizeLevel sizeLevel + ([cargoValue] of aTrader / 10)
end
to rome-mutate-traits
let mVar (item 10 culturalVector) / 100
set culturalVector replace-item 0 culturalVector rome-mutate-trait (item 0 culturalVector) 0 255 mVar
set culturalVector replace-item 8 culturalVector rome-mutate-trait (item 8 culturalVector) 0 1 mVar
end
to-report rome-mutate-trait [ val minV maxV mVar ]
let res val + (random-normal 0 mVar) * (maxV - minV)
report max (list minV min (list maxV res))
end
to-report rome-get-potential-number-of-traders
report floor (1 + (sizeLevel - 1) * (item 8 culturalVector))
end
to-report rome-get-current-number-of-traders
let b self
report count traders with [isActivated and base = b]
end
;; --- VISUALIZATION & PLOTTING ---
to rome-update-display
;; 1. Update Map Visuals
ask settlements [
let visualSize 1 + (log sizeLevel 10)
if visualSize > 5 [ set visualSize 5 ]
set size visualSize
;; Show size label if huge
ifelse sizeLevel > 50
[ set label round sizeLevel ]
[ set label "" ]
]
;; 2. Update Wealth Distribution Plot (Lorenz Curve)
if plot-exists? "Wealth Distribution" [
set-current-plot "Wealth Distribution"
clear-plot
;; A. Perfect Equality Line (Gray)
create-temporary-plot-pen "Equality"
set-plot-pen-color gray
plot 0 plot 0
plot 100 plot 100
;; B. Calculate Inequality
let wealth-list sort [sizeLevel + stock] of settlements
let total-wealth sum wealth-list
let n count settlements
;; C. Reality Line (Red)
create-temporary-plot-pen "Reality"
set-plot-pen-color red
plot 0 plot 0
let accumulated-wealth 0
let i 0
if total-wealth > 0 [
foreach wealth-list [ [w] ->
set accumulated-wealth accumulated-wealth + w
set i i + 1
plotxy ((i / n) * 100) ((accumulated-wealth / total-wealth) * 100)
]
]
]
end
to-report plot-exists? [ name ]
let exists? false
carefully [
set-current-plot name
set exists? true
] [ ]
report exists?
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; A* PATHFINDING ALGORITHM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to-report rome-extract-rgb [ c ]
ifelse is-list? c [ report c ] [ report extract-rgb c ]
end
to-report rome-find-a-path [ start-patch end-patch ]
ask patches [
set f 0
set g 0
set h 0
set parent-patch nobody
]
let open (patch-set start-patch)
let closed (patch-set)
let current start-patch
ask start-patch [
set g 0
set h distance end-patch
set f g + h
]
while [any? open] [
set current min-one-of open [f]
if current = end-patch [
let path (list current)
while [current != start-patch] [
set current [parent-patch] of current
set path fput current path
]
report path
]
set open open with [self != current]
set closed (patch-set closed current)
ask [neighbors] of current [
if not member? self closed and (not isLand or self = end-patch) [
let tentative-g [g] of current + 1
let better-path? false
ifelse member? self open [
if tentative-g < g [
set g tentative-g
set better-path? true
]
] [
set g tentative-g
set better-path? true
set open (patch-set open self)
]
if better-path? [
set h distance end-patch
set f g + h
set parent-patch current
]
]
]
]
report []
end
to-report rome-get-routes-to-settlement [ s ]
report filter [ [r] ->
is-list? r and not empty? r and (
member? s (settlements-on first r) or
member? s (settlements-on last r)
)
] routes
end
to-report rome-get-origin-and-destination [ r ]
report (turtle-set (settlements-on first r) (settlements-on last r))
end
to-report rome-benefit-cost-of-route [ r t ]
let c sum map [ [p] -> rome-get-path-cost p t ] r
let b sum [sizeLevel] of (rome-get-origin-and-destination r)
ifelse c = 0 [ report 0 ] [ report b / c ]
end
to-report rome-get-path-cost [ p t ]
let base-cost [pathCost] of p
if [isLand] of p [
let trait-idx ifelse-value (any? settlements-here) [4] [3]
set base-cost base-cost + (item trait-idx [culturalVector] of [base] of t)
]
report max (list 0.1 base-cost)
end]]></code>
<widgets>
<view x="368" wrappingAllowedX="true" y="8" frameRate="30.0" minPycor="-16" height="439" showTickCounter="true" patchSize="13.2" fontSize="10" wrappingAllowedY="true" width="439" tickCounterLabel="ticks" maxPycor="16" updateMode="0" maxPxcor="16" minPxcor="-16"></view>
<button x="40" y="35" height="40" disableUntilTicks="false" forever="false" kind="Observer" width="55" display="setup">rome-setup</button>
<button x="105" y="35" height="40" disableUntilTicks="false" forever="true" kind="Observer" width="55" display="go">rome-go</button>
<slider x="35" step="1" y="105" max="100000" width="250" display="seed" height="50" min="0" direction="Horizontal" default="10714.0" variable="seed"></slider>
<slider x="35" step="1" y="165" max="100" width="250" display="pondSize" height="50" min="0" direction="Horizontal" default="20.0" variable="pondSize"></slider>
<slider x="35" step="1" y="225" max="100" width="250" display="coastalNoiseLevel" height="50" min="0" direction="Horizontal" default="100.0" variable="coastalNoiseLevel"></slider>
<slider x="35" step="0.1" y="285" max="15" width="250" display="numberOfSettlements" height="50" min="0.1" direction="Horizontal" default="10.0" variable="numberOfSettlements"></slider>
<slider x="35" step="0.1" y="345" max="5" width="250" display="relativePathCostInPort" height="50" min="0.1" direction="Horizontal" default="2.1" variable="relativePathCostInPort"></slider>
<slider x="35" step="1" y="405" max="50" width="250" display="landTechVariation" height="50" min="0" direction="Horizontal" default="20.0" variable="landTechVariation"></slider>
<slider x="30" step="1" y="465" max="20" width="250" display="maxSettlementSizeDecayRate" height="50" min="0.001" direction="Horizontal" default="0.001" variable="maxSettlementSizeDecayRate"></slider>
<slider x="30" step="1" y="525" max="20" width="250" display="maxStockDecayRate" height="50" min="0" direction="Horizontal" default="0.0" variable="maxStockDecayRate"></slider>
<slider x="30" step="1" y="585" max="50" width="250" display="maxProductionRate" height="50" min="0" direction="Horizontal" default="1.0" variable="maxProductionRate"></slider>
<slider x="365" step="1" y="465" max="100" width="250" display="maxTraitTransmissionRate" height="50" min="0" direction="Horizontal" default="50.0" variable="maxTraitTransmissionRate"></slider>
<slider x="365" step="1" y="525" max="20" width="250" display="maxMutationVariation" height="50" min="0" direction="Horizontal" default="20.0" variable="maxMutationVariation"></slider>
<chooser x="365" y="585" height="60" variable="noiseType" current="0" width="250" display="noiseType">
<choice type="string" value="uniform"></choice>
<choice type="string" value="normal"></choice>
</chooser>
<plot x="830" autoPlotX="true" yMax="10.0" autoPlotY="true" y="15" xMin="0.0" height="175" legend="false" xMax="10.0" yMin="0.0" width="230" display="Settlements">
<setup></setup>
<update></update>
<pen interval="1.0" mode="0" display="default" color="-16777216" legend="true">
<setup></setup>
<update>plot count settlements</update>
</pen>
</plot>
<slider x="635" step="1" y="465" max="100" width="250" display="imperial-stability" height="50" min="0" direction="Horizontal" default="100.0" variable="imperial-stability"></slider>
<plot x="835" autoPlotX="true" yMax="10.0" autoPlotY="true" yAxis="% of Wealth" y="205" xMin="0.0" height="250" legend="false" xMax="10.0" yMin="0.0" width="420" xAxis="% of Population" display="Wealth Distribution">
<setup></setup>
<update></update>
<pen interval="1.0" mode="0" display="default" color="-16777216" legend="true">
<setup></setup>
<update>plot count turtles</update>
</pen>
</plot>
</widgets>
<info>## 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)
</info>
<turtleShapes>
<shape name="default" rotatable="true" editableColorIndex="0">
<polygon color="-1920102913" filled="true" marked="true">
<point x="150" y="5"></point>
<point x="40" y="250"></point>
<point x="150" y="205"></point>
<point x="260" y="250"></point>
</polygon>
</shape>
<shape name="airplane" rotatable="true" editableColorIndex="0">
<polygon color="-1920102913" filled="true" marked="true">
<point x="150" y="0"></point>
<point x="135" y="15"></point>
<point x="120" y="60"></point>
<point x="120" y="105"></point>
<point x="15" y="165"></point>
<point x="15" y="195"></point>
<point x="120" y="180"></point>
<point x="135" y="240"></point>
<point x="105" y="270"></point>
<point x="120" y="285"></point>
<point x="150" y="270"></point>
<point x="180" y="285"></point>
<point x="210" y="270"></point>
<point x="165" y="240"></point>
<point x="180" y="180"></point>
<point x="285" y="195"></point>
<point x="285" y="165"></point>
<point x="180" y="105"></point>
<point x="180" y="60"></point>
<point x="165" y="15"></point>
</polygon>
</shape>
<shape name="arrow" rotatable="true" editableColorIndex="0">
<polygon color="-1920102913" filled="true" marked="true">
<point x="150" y="0"></point>
<point x="0" y="150"></point>
<point x="105" y="150"></point>
<point x="105" y="293"></point>
<point x="195" y="293"></point>
<point x="195" y="150"></point>
<point x="300" y="150"></point>
</polygon>
</shape>
<shape name="box" rotatable="false" editableColorIndex="0">
<polygon color="-1920102913" filled="true" marked="true">
<point x="150" y="285"></point>
<point x="285" y="225"></point>
<point x="285" y="75"></point>
<point x="150" y="135"></point>
</polygon>
<polygon color="-1920102913" filled="true" marked="true">
<point x="150" y="135"></point>
<point x="15" y="75"></point>
<point x="150" y="15"></point>
<point x="285" y="75"></point>
</polygon>
<polygon color="-1920102913" filled="true" marked="true">
<point x="15" y="75"></point>
<point x="15" y="225"></point>
<point x="150" y="285"></point>
<point x="150" y="135"></point>
</polygon>
<line endX="150" startY="285" marked="false" color="255" endY="135" startX="150"></line>
<line endX="15" startY="135" marked="false" color="255" endY="75" startX="150"></line>
<line endX="285" startY="135" marked="false" color="255" endY="75" startX="150"></line>
</shape>
<shape name="bug" rotatable="true" editableColorIndex="0">
<circle x="96" y="182" marked="true" color="-1920102913" diameter="108" filled="true"></circle>
<circle x="110" y="127" marked="true" color="-1920102913" diameter="80" filled="true"></circle>
<circle x="110" y="75" marked="true" color="-1920102913" diameter="80" filled="true"></circle>
<line endX="80" startY="100" marked="true" color="-1920102913" endY="30" startX="150"></line>
<line endX="220" startY="100" marked="true" color="-1920102913" endY="30" startX="150"></line>
</shape>
<shape name="butterfly" rotatable="true" editableColorIndex="0">
<polygon color="-1920102913" filled="true" marked="true">
<point x="150" y="165"></point>
<point x="209" y="199"></point>
<point x="225" y="225"></point>
<point x="225" y="255"></point>
<point x="195" y="270"></point>
<point x="165" y="255"></point>
<point x="150" y="240"></point>
</polygon>
<polygon color="-1920102913" filled="true" marked="true">
<point x="150" y="165"></point>
<point x="89" y="198"></point>
<point x="75" y="225"></point>
<point x="75" y="255"></point>
<point x="105" y="270"></point>
<point x="135" y="255"></point>
<point x="150" y="240"></point>
</polygon>
<polygon color="-1920102913" filled="true" marked="true">
<point x="139" y="148"></point>
<point x="100" y="105"></point>
<point x="55" y="90"></point>
<point x="25" y="90"></point>
<point x="10" y="105"></point>
<point x="10" y="135"></point>
<point x="25" y="180"></point>
<point x="40" y="195"></point>
<point x="85" y="194"></point>
<point x="139" y="163"></point>
</polygon>
<polygon color="-1920102913" filled="true" marked="true">
<point x="162" y="150"></point>
<point x="200" y="105"></point>
<point x="245" y="90"></point>
<point x="275" y="90"></point>
<point x="290" y="105"></point>
<point x="290" y="135"></point>
<point x="275" y="180"></point>
<point x="260" y="195"></point>
<point x="215" y="195"></point>
<point x="162" y="165"></point>
</polygon>
<polygon color="255" filled="true" marked="false">
<point x="150" y="255"></point>
<point x="135" y="225"></point>
<point x="120" y="150"></point>
<point x="135" y="120"></point>
<point x="150" y="105"></point>
<point x="165" y="120"></point>
<point x="180" y="150"></point>
<point x="165" y="225"></point>
</polygon>
<circle x="135" y="90" marked="false" color="255" diameter="30" filled="true"></circle>
<line endX="195" startY="105" marked="false" color="255" endY="60" startX="150"></line>
<line endX="105" startY="105" marked="false" color="255" endY="60" startX="150"></line>
</shape>
<shape name="car" rotatable="false" editableColorIndex="0">
<polygon color="-1920102913" filled="true" marked="true">
<point x="300" y="180"></point>
<point x="279" y="164"></point>
<point x="261" y="144"></point>
<point x="240" y="135"></point>
<point x="226" y="132"></point>
<point x="213" y="106"></point>
<point x="203" y="84"></point>
<point x="185" y="63"></point>
<point x="159" y="50"></point>
<point x="135" y="50"></point>
<point x="75" y="60"></point>
<point x="0" y="150"></point>
<point x="0" y="165"></point>
<point x="0" y="225"></point>
<point x="300" y="225"></point>
<point x="300" y="180"></point>
</polygon>
<circle x="180" y="180" marked="false" color="255" diameter="90" filled="true"></circle>
<circle x="30" y="180" marked="false" color="255" diameter="90" filled="true"></circle>
<polygon color="255" filled="true" marked="false">
<point x="162" y="80"></point>
<point x="132" y="78"></point>
<point x="134" y="135"></point>
<point x="209" y="135"></point>
<point x="194" y="105"></point>
<point x="189" y="96"></point>
<point x="180" y="89"></point>
</polygon>
<circle x="47" y="195" marked="true" color="-1920102913" diameter="58" filled="true"></circle>
<circle x="195" y="195" marked="true" color="-1920102913" diameter="58" filled="true"></circle>
</shape>
<shape name="circle" rotatable="false" editableColorIndex="0">
<circle x="0" y="0" marked="true" color="-1920102913" diameter="300" filled="true"></circle>
</shape>
<shape name="circle 2" rotatable="false" editableColorIndex="0">
<circle x="0" y="0" marked="true" color="-1920102913" diameter="300" filled="true"></circle>
<circle x="30" y="30" marked="false" color="255" diameter="240" filled="true"></circle>
</shape>
<shape name="cow" rotatable="false" editableColorIndex="0">
<polygon color="-1920102913" filled="true" marked="true">
<point x="200" y="193"></point>
<point x="197" y="249"></point>
<point x="179" y="249"></point>
<point x="177" y="196"></point>
<point x="166" y="187"></point>
<point x="140" y="189"></point>
<point x="93" y="191"></point>
<point x="78" y="179"></point>
<point x="72" y="211"></point>
<point x="49" y="209"></point>
<point x="48" y="181"></point>
<point x="37" y="149"></point>
<point x="25" y="120"></point>
<point x="25" y="89"></point>
<point x="45" y="72"></point>
<point x="103" y="84"></point>
<point x="179" y="75"></point>
<point x="198" y="76"></point>
<point x="252" y="64"></point>
<point x="272" y="81"></point>
<point x="293" y="103"></point>
<point x="285" y="121"></point>
<point x="255" y="121"></point>
<point x="242" y="118"></point>
<point x="224" y="167"></point>
</polygon>
<polygon color="-1920102913" filled="true" marked="true">
<point x="73" y="210"></point>
<point x="86" y="251"></point>
<point x="62" y="249"></point>
<point x="48" y="208"></point>
</polygon>
<polygon color="-1920102913" filled="true" marked="true">
<point x="25" y="114"></point>
<point x="16" y="195"></point>
<point x="9" y="204"></point>
<point x="23" y="213"></point>
<point x="25" y="200"></point>
<point x="39" y="123"></point>
</polygon>
</shape>
<shape name="cylinder" rotatable="false" editableColorIndex="0">
<circle x="0" y="0" marked="true" color="-1920102913" diameter="300" filled="true"></circle>
</shape>
<shape name="dot" rotatable="false" editableColorIndex="0">
<circle x="90" y="90" marked="true" color="-1920102913" diameter="120" filled="true"></circle>
</shape>
<shape name="face happy" rotatable="false" editableColorIndex="0">
<circle x="8" y="8" marked="true" color="-1920102913" diameter="285" filled="true"></circle>
<circle x="60" y="75" marked="false" color="255" diameter="60" filled="true"></circle>
<circle x="180" y="75" marked="false" color="255" diameter="60" filled="true"></circle>
<polygon color="255" filled="true" marked="false">
<point x="150" y="255"></point>
<point x="90" y="239"></point>
<point x="62" y="213"></point>
<point x="47" y="191"></point>
<point x="67" y="179"></point>
<point x="90" y="203"></point>
<point x="109" y="218"></point>
<point x="150" y="225"></point>
<point x="192" y="218"></point>
<point x="210" y="203"></point>
<point x="227" y="181"></point>
<point x="251" y="194"></point>
<point x="236" y="217"></point>
<point x="212" y="240"></point>
</polygon>
</shape>
<shape name="face neutral" rotatable="false" editableColorIndex="0">
<circle x="8" y="7" marked="true" color="-1920102913" diameter="285" filled="true"></circle>
<circle x="60" y="75" marked="false" color="255" diameter="60" filled="true"></circle>
<circle x="180" y="75" marked="false" color="255" diameter="60" filled="true"></circle>
<rectangle endX="240" startY="195" marked="false" color="255" endY="225" startX="60" filled="true"></rectangle>
</shape>
<shape name="face sad" rotatable="false" editableColorIndex="0">
<circle x="8" y="8" marked="true" color="-1920102913" diameter="285" filled="true"></circle>
<circle x="60" y="75" marked="false" color="255" diameter="60" filled="true"></circle>
<circle x="180" y="75" marked="false" color="255" diameter="60" filled="true"></circle>
<polygon color="255" filled="true" marked="false">
<point x="150" y="168"></point>
<point x="90" y="184"></point>
<point x="62" y="210"></point>
<point x="47" y="232"></point>
<point x="67" y="244"></point>
<point x="90" y="220"></point>
<point x="109" y="205"></point>
<point x="150" y="198"></point>
<point x="192" y="205"></point>
<point x="210" y="220"></point>
<point x="227" y="242"></point>
<point x="251" y="229"></point>
<point x="236" y="206"></point>
<point x="212" y="183"></point>
</polygon>
</shape>
<shape name="fish" rotatable="false" editableColorIndex="0">
<polygon color="-1" filled="true" marked="false">
<point x="44" y="131"></point>
<point x="21" y="87"></point>
<point x="15" y="86"></point>
<point x="0" y="120"></point>
<point x="15" y="150"></point>
<point x="0" y="180"></point>
<point x="13" y="214"></point>
<point x="20" y="212"></point>
<point x="45" y="166"></point>
</polygon>
<polygon color="-1" filled="true" marked="false">
<point x="135" y="195"></point>
<point x="119" y="235"></point>
<point x="95" y="218"></point>
<point x="76" y="210"></point>
<point x="46" y="204"></point>
<point x="60" y="165"></point>
</polygon>
<polygon color="-1" filled="true" marked="false">
<point x="75" y="45"></point>
<point x="83" y="77"></point>
<point x="71" y="103"></point>
<point x="86" y="114"></point>
<point x="166" y="78"></point>
<point x="135" y="60"></point>
</polygon>
<polygon color="-1920102913" filled="true" marked="true">
<point x="30" y="136"></point>
<point x="151" y="77"></point>
<point x="226" y="81"></point>
<point x="280" y="119"></point>
<point x="292" y="146"></point>
<point x="292" y="160"></point>
<point x="287" y="170"></point>
<point x="270" y="195"></point>
<point x="195" y="210"></point>
<point x="151" y="212"></point>
<point x="30" y="166"></point>
</polygon>
<circle x="215" y="106" marked="false" color="255" diameter="30" filled="true"></circle>
</shape>
<shape name="flag" rotatable="false" editableColorIndex="0">
<rectangle endX="75" startY="15" marked="true" color="-1920102913" endY="300" startX="60" filled="true"></rectangle>
<polygon color="-1920102913" filled="true" marked="true">
<point x="90" y="150"></point>
<point x="270" y="90"></point>