Lanchester 3-way combat

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 83 times • Downloaded 5 times • Run 0 times
Download the 'Lanchester 3-way combat' 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]
breed[rojos rojo]
breed[azules azul]
breed[rosas rosa]

to setup
clear-all
  ask patches [set pcolor green - random-float 2]
  create-rojos R[set shape "person" set color red set vision random V set efectividad random-float E set ip random-float 1
    set xcor -10 + random filas set ycor 10 - 0.5 * random world-height  set amigo one-of rojos in-radius vision
    ifelse tipoEnfrentamiento = "fila" [set heading 90][set heading random 180]]
  create-rosas R[set shape "person" set color pink set vision random V set efectividad random-float E set ip random-float 1
    set xcor random-xcor  set ycor 10 + random filas set amigo one-of rosas in-radius vision
    ifelse tipoEnfrentamiento = "fila" [set heading 90][set heading random 90]]
  create-azules A[set shape "person" set color blue set vision random V set efectividad random-float E set ip random-float 1
    set xcor 10 + random filas set ycor 10 - 0.5 * random world-height set amigo one-of azules in-radius vision
    ifelse tipoEnfrentamiento = "fila" [set heading -90][set heading random -180]]
reset-ticks
end 

to go
  if not any? rojos and not any? rosas[ user-message "Ganan los azules" stop ]
  if not any? azules and not any? rosas[ user-message "Ganan los rojos" stop ]
  if not any? azules and not any? rojos[ user-message "Ganan los rosas" stop ]

  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]] ]
  tick
end 

to dispara
  apunta if random-float 1 > efectividad[if blanco != nobody [ask blanco [die]]] apunta
end 

to apunta
  ifelse breed = rojos[let b one-of other turtles with [breed != rojos] in-radius vision set blanco b]
  [ifelse breed = azules[let b one-of other turtles with [breed != azules] in-radius vision set blanco b][let b one-of other turtles with [breed != rosas] in-radius vision set blanco b]]
  ifelse blanco != nobody [set heading (towards blanco)][ifelse breed = rojos[set heading random 180][ifelse breed = azules [set heading random -180][set heading -90]]]
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 rojos in-radius vision][ifelse breed = azules[set amigo one-of azules in-radius vision][set amigo one-of rosas in-radius vision]]
end 

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

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.