Irish and English

Irish and English preview image

1 collaborator

Tags

conflict 

Tagged by Vinicius Marino Carvalho about 7 years ago

cooperation 

Tagged by Vinicius Marino Carvalho about 7 years ago

history 

Tagged by Vinicius Marino Carvalho about 7 years ago

war 

Tagged by Vinicius Marino Carvalho about 7 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.1 • Viewed 691 times • Downloaded 35 times • Run 0 times
Download the 'Irish and English' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

How do I download this model? (Question)

Hi, I am having difficulty downloading this model. Anytime I attempt to download, a dialogue box pop up saying Windows cannot complete the extraction/The destination file could not be created. I will appreciate any advice or link, please. Thank you. Kind regards. Muhammad

Posted almost 6 years ago

Click to Run Model

breed [ irish an-irish ]
breed [ english an-english ]

undirected-link-breed [ alliances alliance ]
undirected-link-breed [ wars war ]
directed-link-breed [ alliance-requests alliance-request ]

globals [
power-english ;; sum of the power of all English agents
power-irish ;;   sum of the power of all Irish agents
]

turtles-own [
  power
  ally-power
  war-effort
  bellicosity
  allies?
]
irish-own [ stability ]

to setup
  clear-all
  setup-agents
  ask turtles [
    set allies? count alliance-neighbors
  ]
  reset-ticks
end 

to setup-agents
  set-default-shape irish "crown"
  ask  n-of (num-irish) patches with [ count turtles-here = 0 ] [   ;; an alternative procedure to create turtles. Makes it easier to work with the Voronoi diagram
      sprout-irish 1[
        set color 53
        set stability 1.0
        set power irish-power * stability
        set size ( 1 + 2 * ( power / 100 ) )                       ;; sizes matches the power meter. The stronger the agent, the bigger it is.
        set bellicosity irish-bellicosity
  ]
  ]
  set-default-shape english "chess rook"
  ask  n-of (num-english) patches with [ count turtles-here = 0 ] [
      sprout-english 1[
        set color 13
        set power english-power
        set size ( 1 + 2 * ( power / 100 ) )
        set bellicosity english-bellicosity
    ]
  ]
  ask patches [refresh-territory]
end 

to go
  ask wars [ die ]                                               ;; unlike alliance requests, wars are killed at the beginning of a tick, so we can see which ones have formed at each tick
  set power-english  sum [ power ] of english                    ;; set up "power" as a global variable so it can be plotted
  set power-irish sum [ power ] of irish
  if not any? irish [ stop ]                                     ;; if there are no agents of any one breed, stops the simulation
  if not any? english [ stop ]
  ask turtles [
    set allies? count alliance-neighbors
    replenish-power
    offer-alliance
    accept-alliance
    declare-war
    opt-out
    wage-war
    set size ( 1 + 2 * ( power / 100 ) )
    perish
  ]
  ask patches [
  refresh-territory
  ]
  ask alliance-requests [ die ]
  tick
end 

;; Environment Procedures

to refresh-territory
  set pcolor [color + 2] of min-one-of turtles [distance myself]       ;; this is the code that generates the Voronoi diagram
end 


;; Turtle Procedures

to replenish-power
  set power ( power + 10 )
  if power >= 100 [                                  ;; power needs to be capped, lest it baloons indefinitely
    set power 100
  ]
  if breed = irish and stability? [ set power ( stability * power ) ]
end 

to offer-alliance
    if allies? = 0 [
    if any? other turtles with [ allies? = 0 ] [
    ask one-of other turtles with [ allies? = 0] [
    create-alliance-request-from myself]
  ask alliance-requests [ set color yellow ]          ;; alliance-requests are colored yellow for debugging purposes only. Since they are killed the same time unit they are generated, we never get to see them
  ]
    ]
  if allies? > 0 [
    set bellicosity bellicosity - 0.1
    if bellicosity <= 0 [                            ;; bellicosity needs to be capped, lest it drop below 0.0
      set bellicosity 0
    ]
  ]
end 

to accept-alliance
  if any? in-alliance-request-neighbors with [ power >= [power] of myself  ] [
    ask out-alliance-neighbors [ die ]                                            ;; agents suspend offers of alliance if they happen to receive a favorable one. This is to ensure each agent gets only one ally.
    if any? alliance-request-neighbors [
    create-alliance-with one-of alliance-request-neighbors
    ]
  ask alliances [
    set color white
  ]
  ]
end 

to declare-war
  if warfare = "all-out" [
    if any? other turtles with [ not alliance-neighbor? myself and power <= [ power ] of myself ] [              ;; agents won't wage wars with enemies more powerful than themselves
   if random-float 1.0 < bellicosity [                                                                           ;; the "roll" that determines propensity to declare war
    ask one-of other turtles with [ not alliance-neighbor? myself and power <= [ power ] of myself ]
   [ create-war-with myself]
   ask wars [ set color black]
   ]
    ]
  ]
  if warfare = "irish-english" [
    if any? other turtles with [ not alliance-neighbor? myself and power <= [ power ] of myself and breed !=[ breed ] of myself ] [
    if random-float 1.0 < bellicosity [
      ask one-of other turtles with [ not alliance-neighbor? myself and power <= [ power ] of myself and breed !=[ breed ] of myself ]
    [ create-war-with myself]
     ask wars [ set color black]
   ]
 ]
  ]
end 


To opt-out
  if any? alliance-neighbors with [ any? war-neighbors ] [
    if any? alliance-neighbors with [ power < 0.5 * [power] of myself ] [              ;; if an agent gets too weak, its allies will ditch it.
    ask my-alliances [ die ]
  ]
  ]
end 

to wage-war
  set ally-power sum [ power ] of alliance-neighbors
  set war-effort power + ally-power
  ask war-neighbors [
    ifelse ( [ war-effort ] of self ) * random-float 1.0 < ( [ war-effort ] of myself )     ;; calculation that determines the outcome of wars
    [ set power ( power - random-float 30 )
      set bellicosity bellicosity + 0.1
      if bellicosity > 1 [ set bellicosity 1 ]
        if breed = irish and stability? [ set stability stability - 0.1 ]                   ;; irish agents lose stability when defeated
    ]
    [ set power ( power - random-float 10 )                                                 ;; loss of power due to attrition and war expenses
      set bellicosity bellicosity + 0.1
      if bellicosity > 1 [ set bellicosity 1 ]
        if breed = irish and stability? [ set stability stability - 0.1 ]
    ]
  ]
end 

to perish
    if power <= 0 [ die ]
end 


;; Interface Button Procedures

to clear-alliances
  ask alliances [ die ]
end 

to provoke-english
  ask english [ set bellicosity bellicosity + 0.1 ]
end 

to provoke-irish
  ask irish [ set bellicosity bellicosity + 0.1 ]
end 

There is only one version of this model, created about 7 years ago by Vinicius Marino Carvalho.

Attached files

File Type Description Last updated
Irish and English.png preview Preview for 'Irish and English' about 7 years ago, by Vinicius Marino Carvalho Download

This model does not have any ancestors.

This model does not have any descendants.