powered by NetLogo
view/download model file: KURSK.nlogo
This section could give a general understanding of what the model is trying to show or explain.
This section could explain what rules the agents use to create the overall behavior of the model.
This section could explain how to use the model, including a description of each of the items in the interface tab.
This section could give some ideas of things for the user to notice while running the model.
This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.
breed[infantries infantry]
breed[tanks tank]
breed[deathstars deathstar]
turtles-own [
range ;over how many patches can agents attack
power ;how strong an accurate attack will be
oDefense ;Original Defense
defense ;how strong an attack an individual can endure
speed ;how many patches an agent can cover in a tick
soviet? ;True for Soviets, false for Germans
target ;who the agent is shooting at
tempDef ;temporary HP loss
accuracy ;Accuracy
amount ;How Many
]
globals [ initGermans initRussians x y GermanRetreat? GermanCapture?]
to setup
clear-all
set GermanRetreat? false;
set GermanCapture? false;
import-drawing "map3.jpg"
createSoviets
createGermans
set initGermans (sum [amount] of turtles with [soviet? = false])
set initRussians (sum [amount] of turtles with [soviet?])
end
to createSoviets
set-default-shape infantries "person"
create-infantries 200 * 12 / Units_per_Unit_Represented [
set x random-normal 11 1
set y random-normal 0 4
if x > 16 [ set x 15.9 ]
if y > 16 [ set y 15.9 ]
if x < -16 [ set x -15.9 ]
if y < -16 [ set y -15.9 ]
setxy x y
facexy -2 0
set color red
set speed .1
set range 2
set power .5
set defense 1
set accuracy .5
set amount Units_per_Unit_Represented
set oDefense amount * defense
set soviet? true]
set-default-shape tanks "tank"
create-tanks 52 * 12 / Units_per_Unit_Represented [
set x random-normal 11 1
set y random-normal 0 3
if x > 16 [ set x 15.9 ]
if y > 16 [ set y 15.9 ]
if x < -16 [ set x -15.9 ]
if y < -16 [ set y -15.9 ]
setxy x y
facexy -2 0
set color red
set size 1.4
set speed .1
set range 3
set power 12
set defense 10
set accuracy 3
set amount Units_per_Unit_Represented
set oDefense amount * defense
set soviet? true]
end
to createGermans
set-default-shape infantries "person"
create-infantries 36 * 36 / Units_per_Unit_Represented [
setxy random-normal -15.8 .25 random-normal -3 2
facexy 11 0
set color grey
set speed .17
set range 2
set power .6
set defense 1.2
set accuracy .7
set amount Units_per_Unit_Represented
set oDefense amount * defense
set soviet? false]
;German 3rd Panzerkorps
set-default-shape tanks "tank"
create-tanks 12 * 12 / Units_per_Unit_Represented [
setxy -16 -1
facexy 11 0
set color grey
set size 1.4
set speed .17
set range 5
set power 25
set defense 13
set accuracy 16
set amount Units_per_Unit_Represented
set oDefense amount * defense
set soviet? false]
if deathstar? [
;Hitler's Deathstar
set-default-shape deathstars "deathstar"
create-deathstars 1 [
setxy -16 -1
facexy 11 0
set amount 1
set color grey
set speed .17
set range 200
set power 2500
set defense 60000
set oDefense 60000
set accuracy 1024
set size 4
set soviet? false]
]
set-default-shape tanks "tank"
;German 1st Panzerkorps
create-tanks 12 * 12 / Units_per_Unit_Represented [
setxy -16 -3
facexy 11 0
set color grey
set size 1.4
set speed .17
set range 5
set power 30
set defense 13
set oDefense amount * defense
set accuracy 16
set amount Units_per_Unit_Represented
set soviet? false]
;German 2nd Panzerkorps
create-tanks 12 * 12 / Units_per_Unit_Represented [
setxy -16 -5
facexy 11 0
set color grey
set size 1.4
set speed .17
set range 5
set power 30
set defense 13
set oDefense amount * defense
set accuracy 16
set amount Units_per_Unit_Represented
set soviet? false]
end
to drawXXIV
;German 3rd Panzerkorps
set-default-shape tanks "tank"
create-tanks 12 * 12 / Units_per_Unit_Represented [
setxy -16 -1
facexy 11 0
set color grey
set size 1.4
set speed .2
set range 5
set power 30
set defense 13
set oDefense amount * defense
set accuracy 16
set amount Units_per_Unit_Represented
set soviet? false]
end
to advance
ask turtles [
ifelse ( (target != 0) and (target != nobody ) )
[face target]
[if (soviet? = false) [facexy 11 0]
right ((random-float 10) - 5)
ask turtles in-radius range [
ifelse ([soviet?] of myself != soviet?)
[ask myself [ set target myself ]]
[if patch-ahead 1 = nobody
[facexy 11 0]]]]
if not ( soviet? and (ticks < 16) ) [
forward speed
]
]
end
to retreat
ask turtles[
facexy min-pxcor min-pycor
ifelse (soviet? = true)
[ifelse ( (target != 0) and (target != nobody ) )
[face target]
[right ((random-float 10) - 5)
ask turtles in-radius range [
if ([soviet?] of myself != soviet?)
[ask myself [ set target myself ]]]]]
[if( (target = 0) or (target = nobody ) )
[right ((random-float 10) - 5)
ask turtles in-radius range [
if ([soviet?] of myself != soviet?)
[ask myself [ set target myself ]]]]]
forward speed]
end
to renforce
ask turtles with [soviet?] [
facexy 11 0
ifelse (soviet? = false)
[ifelse ( (target != 0) and (target != nobody ) )
[face target]
[right ((random-float 10) - 5)
ask turtles in-radius range [
if ([soviet?] of myself != soviet?)
[ask myself [ set target myself ]]]]]
[if( (target = 0) or (target = nobody ) )
[right ((random-float 10) - 5)
ask turtles in-radius range [
if ([soviet?] of myself != soviet?)
[ask myself [ set target myself ]]]]]
forward speed]
end
to attack
ask turtles [
if ( target != 0 and target != nobody) [
create-link-to target [
set color [color] of myself
hide-link
]
if ( target != 0 and target != nobody) [
ask target [
set tempDef tempDef + (power * ( ( random-normal .5 .25 ) * [accuracy] of myself ) / ( ( [xcor]
#### of myself - xcor ) * ( [xcor] of myself - xcor ) + ( [ycor] of myself - ycor ) *
#### ( [ycor] of myself - ycor )) * ([oDefense] of myself / [defense] of myself / [amount] of myself))
]]
`
]]
end
to do
ask turtles [
set x floor( tempDef / defense )
set amount amount - max fput x [ 0 ]
set tempDef 0
if ( amount < 1 ) [die]
]
end
to do-plots
set-current-plot "Forces"
set-current-plot-pen "Soviet"
plot (sum [amount] of turtles with [soviet?] )
set-current-plot-pen "German"
plot (sum [amount] of turtles with [soviet? = false] )
end
to go
clear-links
if XXIV_Activated? and (ticks = 50)
[drawXXIV]
ifelse (German_Retreat? and (ticks > 100))
[retreat]
[advance]
attack
if (count turtles with [soviet? = false] = 0)
[output-print "Soviet Victory."
stop]
if (sum [amount] of turtles at-points [[11 0]] with [soviet? = false] > 0) [
output-print "German Capture."
set GermanCapture? true
renforce
;todo if captured, Soviets head toward 11 0
if (Deathmatch? = false) [stop]]
if (sum [amount] of turtles at-points [[-16 -16]] with [soviet? = false] > 0) [
output-print "German Retreat."
;todo if captured, Soviets head toward 11 0
set GermanRetreat? true
if (Deathmatch? = false) [stop]]
if (sum [amount] of turtles with [soviet? = true] = 0)
[if (German_Retreat? = true ) [output-print "German Escape."]
stop]
do
ask links [ hide-link ]
tick
do-plots
end