Lanchester 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 75 times • Downloaded 2 times • Run 0 times
Download the 'Lanchester 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]
breed[rojos rojo]
breed[azules azul]

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 random-ycor set amigo one-of rojos in-radius vision
    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 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]]
reset-ticks
end 

to go
  ask turtles[ifelse tipoEnfrentamiento = "perseguir" [rt random 180 fd 1 apunta ifelse blanco != nobody
    [ifelse ip > 0.5 [apunta get_amigo huir][get_amigo apunta pleitear apunta dispara]][fd 1]] [fd 1 apunta ifelse blanco != nobody
    [ifelse ip > 0.5 [apunta get_amigo huir][get_amigo apunta pleitear apunta dispara]][fd 1]] ]
  tick
end 

to dispara
  apunta if random-float 1 > efectividad[ask blanco [die]] apunta
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 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][set amigo one-of azules in-radius vision]
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.