Lanchester Guerrilla warfare II

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 68 times • Downloaded 2 times • Run 0 times
Download the 'Lanchester Guerrilla warfare II' modelDownload this modelEmbed this model

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

turtles-own[vision blanco efectividad amigo ip]
globals[bajas_fa bajas_c]
patches-own[cobertura]

breed[rojos rojo] ;guerrilla
breed[azules azul];regulares
breed[grises gris];civiles

rojos-own[brigada cubierta pop]
azules-own[pop ]

to setup
clear-all
  set bajas_fa 0 set bajas_c 0
  ask patches [set cobertura random-float 5 set pcolor green - cobertura ]
  create-rojos R[set shape "person" set color red set vision random V set efectividad random-float E set ip random-float 1
    set brigada random brigadas set pop random-exponential 10
    set xcor (- brigada + random filas) set ycor random-ycor set cubierta [cobertura] of patch-here set amigo one-of other rojos with [brigada = brigada]
    ifelse tipoEnfrentamiento = "fila" [set heading 90][set heading random 180]]
  create-azules A[set shape "person" set color blue set vision random V set efectividad random-float E set ip random-float 1 set pop random-exponential 10
    set xcor 10 + random filas set ycor random-ycor set amigo one-of azules in-radius vision
    ifelse tipoEnfrentamiento = "fila" [set heading -90][set heading random -180]]
  create-grises C[set shape "person" set color grey setxy random-xcor random-ycor]
reset-ticks
end 

to go
  if not any? rojos [ user-message "Ganan los azules" stop ]
  if not any? azules [ user-message "Ganan los rojos" stop ]
  ask rojos [reune-brigada busca-cobertura]
  ask turtles[ifelse tipoEnfrentamiento = "perseguir" [rt random 180 fd random-float 2 apunta ifelse blanco != nobody
    [ifelse ip > 0.5 [apunta get_amigo huir][get_amigo apunta pleitear apunta dispara]][fd random-float 1]
    ]
    [fd random-float 2 apunta ifelse blanco != nobody
    [ifelse ip > 0.5 [apunta get_amigo huir][get_amigo apunta pleitear apunta dispara]][fd random-float 1]] ]
  ask grises[mueve-gris if bajas_c >= UmbralCiviles * count grises [ifelse pop_media_roja > pop_media_azul [ask n-of (random-float RecRojo * count grises) grises [vuelve-rojo] ] [ask n-of (random-float RecAzul * count grises) grises [vuelve-azul]]] ]
  tick
end 

to vuelve-rojo
  set breed rojos set shape "person" set color red set vision random V set efectividad random-float E set ip random-float 1
    set brigada random brigadas set pop random-exponential 10
    set xcor (- brigada + random filas) set ycor random-ycor set cubierta [cobertura] of patch-here set amigo one-of other rojos with [brigada = brigada]
end 

to vuelve-azul
 set breed azules set shape "person" set color blue set vision random V set efectividad random-float E set ip random-float 1 set pop random 10 set amigo one-of azules in-radius vision
end 

to mueve-gris
  rt random 90 lt random 90 fd random 10
end 

to reune-brigada
  ifelse amigo != nobody [ set heading towards amigo  fd random 10][get_amigo]
end 

to busca-cobertura
  let spot max-one-of patches in-radius vision [cobertura]
  if spot != nobody[set heading towards spot fd random 10]
end 

to apunta
  ifelse breed = rojos[let b one-of azules in-radius vision set blanco b][let b one-of rojos in-radius vision set blanco b]
  ifelse blanco != nobody [set heading (towards blanco)][ifelse breed = rojos[set heading random 180][set heading random -180]]
end 

to dispara-rojo
  apunta ifelse random-float 1 > efectividad[if blanco != nobody and [cubierta] of blanco < 2.5[ask blanco [die]]][if blanco != nobody [let colateral one-of other turtles-here
    if colateral != nobody [ask colateral[ if breed != azules[ifelse breed = rojos [set bajas_fa bajas_fa + 1][set bajas_c bajas_c + 1]] die] set pop pop - 1 ]]] apunta
end 

to dispara-azul
  apunta ifelse random-float 1 > efectividad[if blanco != nobody [ask blanco [die]]][if blanco != nobody [let colateral one-of other turtles-here
    if colateral != nobody[ask colateral[if breed != rojos[ifelse breed = azules [set bajas_fa bajas_fa + 1][set bajas_c bajas_c + 1]] die] set pop pop - 1]  ]] apunta
end 

to dispara
  ifelse breed = rojos[dispara-azul][dispara-rojo]
end 

to pleitear
  ;; move toward the midpoint of your friend and enemy
  facexy ([xcor] of amigo + [xcor] of blanco) / 2
         ([ycor] of amigo + [ycor] of blanco) / 2
  fd 0.1
end 

to huir
  ;; put your friend between you and your enemy
  facexy [xcor] of amigo + ([xcor] of amigo - [xcor] of blanco) / 2
        [ycor] of amigo + ([ycor] of amigo - [ycor] of blanco) / 2
  fd 0.1
end 

to get_amigo
  ifelse breed = rojos[set amigo one-of other rojos with [brigada = brigada]][set amigo one-of azules in-radius vision]
end 

to-report pop_media_roja
  ifelse count rojos != 0 [report mean [pop] of rojos][report 0]
end 

to-report pop_media_azul
  ifelse count azules != 0 [report mean [pop] of azules][report 0]
end 

There is only one version of this model, created 5 months ago by Augusto Cabrera-Becerril.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.