battlefield
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
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)
Comments and Questions
turtles-own [ life attack enemy-insight enemy-around nearest-enemy attackee side] to setup clear-all set-default-shape turtles "dot" let red-pos patches with [ pxcor < -10 and pxcor > -13 and pycor < 3 and pycor > -3 ] let blue-pos patches with [ pxcor < 30 and pxcor > 10 and pycor < 1 and pycor > -1 ] ask red-pos [ sprout 1 [ set color red set size 2 set heading 90 set side 15 ] ] ask blue-pos [ sprout 1 [ set color blue set size 2 set heading -90 set side 105 ] ] ask turtles [ set life initial-life set attack preset-attack update-color ] reset-ticks end to go if (not any? turtles with [side = 15]) or (not any? turtles with [side = 105]) [stop] ask turtles [ check-death update-color explore direct move target fight ] tick end to explore search-enemy-insight if any? enemy-insight [ set nearest-enemy min-one-of enemy-insight [distance myself] ] find-enemy-around if any? enemy-around [ set attackee one-of enemy-around ] end to direct ifelse any? enemy-around [ face attackee ][ ifelse any? enemy-insight [ face nearest-enemy ][ wiggle ] ] end to wiggle ; rt random 30 ; lt random 30 end to move if not any? turtles-on patch-ahead 1 [ forward 1 setxy pxcor pycor ] end to target find-enemy-around if any? enemy-around [ set attackee one-of enemy-around ] end to fight if any? enemy-around [ ask attackee [ set life life - [attack] of myself - (5 - random-float 10)] ] end to search-enemy-insight set enemy-insight (turtles in-radius vision) with [ side != [side] of myself ] end to find-enemy-around set enemy-around (turtles-on neighbors) with [ side != [side] of myself ] end to check-death if life <= 0 [die] end to update-color set color scale-color side (initial-life - life) (- initial-life) (2 * initial-life) set label (precision life 0) end
There is only one version of this model, created over 12 years ago by Dajun Yue.
This model does not have any ancestors.
This model does not have any descendants.