Warring States
No preview image
Model was written in NetLogo 5.0RC6
•
Viewed 370 times
•
Downloaded 35 times
•
Run 2 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 [ nation-colors ] patches-own [ capital ;; capitals are turtles. every patch knows which turtle ;; is the capital of its state. ] to setup clear-all set-default-shape turtles "dot" ;; hopefully these colors are visually distinguishable set nation-colors (sentence base-colors (map [? + 3] base-colors) (map [? - 3] base-colors)) ask patches [ set capital nobody ] ;; We start with 14 nations because that's how ;; many base colors NetLogo has. With more than ;; 14 nations we'd have trouble giving them each ;; a unique, easily visually distinguishable color. ask n-of (length nation-colors) patches [ sprout 1 [ set size 2 ;; easier to see set color black set pcolor item who nation-colors set capital self ] ] grow-nations reset-ticks end to grow-nations ;; This is some arbitrary code that gives a rough, randomized ;; approximation of a Voronoi diagram, to use as a plausible ;; initial state for the system. loop [ let empty patches with [capital = nobody] if not any? empty [ stop ] ask empty [ set capital [capital] of one-of neighbors4 if capital != nobody [ set pcolor [pcolor] of capital ] ] ] end to go if count turtles = 1 [ stop ] ;; first find two adjacent patches that differ in color let attacker nobody let target nobody while [target = nobody] [ set attacker one-of patches ask attacker [ set target one-of neighbors4 with [capital != [capital] of myself] ] ] ;; now attack! ask target [ set pcolor [pcolor] of attacker set capital [capital] of attacker ] let sacked one-of turtles-on target if sacked != nobody [ ask patches with [capital = sacked ] [ set pcolor [pcolor] of attacker set capital [capital] of attacker ] ask sacked [ die ] ] ;; we're done, so advance the tick counter tick end
There are 2 versions of this model.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.