Lanchester Combat Model
Model was written in NetLogo 6.4.0
•
Viewed 77 times
•
Downloaded 9 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
breed[force-units force-unit] force-units-own[ force-range accuracy ] globals [ separated-forces? accuracy-deviation free-move battle-move ] to setup-globals set separated-forces? false set accuracy-deviation 0 set free-move 0 set battle-move 0 end to startup set initial-blue-forces 2000 set initial-red-forces 2050 set blue-accuracy 1 set red-accuracy 1 set blue-range max-range + 1 set red-range max-range + 1 set blue-area-fire? false set red-area-fire? false setup end to setup clear-all setup-globals setup-forces reset-ticks end to go if battle-finished? [ stop ] go-forces tick end to-report max-range report ceiling sqrt ( max-pxcor * max-pxcor + max-pycor * max-pycor ) end to setup-forces spwan-blue-forces spawn-red-forces end to setup-accuracy [accuracy-mean accuracy-standard-deviation] ifelse accuracy-standard-deviation > 0 [ set accuracy random-normal accuracy-mean accuracy-standard-deviation ] [ set accuracy accuracy-mean ] set accuracy min list 1 accuracy set accuracy max list 0 accuracy end to spwan-blue-forces create-force-units initial-blue-forces [ set color blue ifelse separated-forces? [ set xcor random-xcor set ycor (max-pycor / 2) + random-float (max-pycor / 2) if random 2 = 1 [ set ycor (- ycor) ] ] [ setxy random-xcor random-ycor ] setup-accuracy blue-accuracy accuracy-deviation set force-range blue-range ] end to spawn-red-forces create-force-units initial-red-forces [ set color red ifelse separated-forces? [ set xcor random-xcor set ycor (random-ycor / 2) ] [ setxy random-xcor random-ycor ] setup-accuracy red-accuracy accuracy-deviation set force-range red-range ] end to go-forces ask force-units [ force-unit-attack ] end to-report hostile-force-units report force-units with [color != [color] of myself] end to-report force-unit-select-target let target nobody let area-fire? ((color = blue and blue-area-fire?) or (color = red and red-area-fire?)) ifelse area-fire? [ let target-patch one-of patches if force-range < max-range [ set target-patch one-of patches in-radius force-range ] ask target-patch [ if any? force-units-here [ set target one-of force-units-here ] ] ] [ let targets hostile-force-units if force-range < max-range [ set targets targets in-radius force-range ] set target min-one-of targets [distance myself] ] report target end to force-unit-attack let target force-unit-select-target ifelse target != nobody [ face target if random-float 1 < (accuracy ^ (distance target)) [ ask target [ die ] ] force-unit-move battle-move ] [ force-unit-move free-move ] end to force-unit-move [ steps ] if steps > 0 [ if any? hostile-force-units [ let target min-one-of hostile-force-units [distance myself] face target ] forward steps ] end to-report battle-finished? report not any? turtles with [color = red] or not any? turtles with [color = blue] end to scenario-one set initial-blue-forces 2000 set initial-red-forces 2050 set blue-accuracy 0.95 set red-accuracy 0.9 set blue-range max-range + 1 set red-range max-range + 1 setup end to scenario-two set initial-blue-forces 1800 set blue-accuracy 0.62 set blue-range 5 set initial-red-forces 2000 set red-accuracy 0.6 set red-range max-range + 1 clear-all set separated-forces? true set accuracy-deviation 0.1 set free-move 1 set battle-move 0.25 setup-forces reset-ticks end
There are 4 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Lanchester Combat Model.png | preview | Preview for 'Lanchester Combat Model' | 2 months ago, by Thomas Rieth | Download |
This model does not have any ancestors.
This model does not have any descendants.