Mafia Model

Mafia Model preview image

1 collaborator

Default-person Benedito Neto (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.4 • Viewed 540 times • Downloaded 21 times • Run 0 times
Download the 'Mafia Model' 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

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [endowment]                                                                                  ; The Patch represents a previous endowment which simulates the market dynamics, with the
                                                                                                     ; possibility of getting profits as the storeowners interact.
breed [mafious a-mafious]
breed [cops a-cop]
breed [storeowners a-storeowner]
turtles-own [money]
patches-own [countdown]

to setup
  clear-all
  ask patches [set pcolor green]
  if endowment? [ask patches
  [ set countdown random-exponential 360 endowment-return                  ; Definition of the countdown of the patches   
   set pcolor one-of [green red]                                           ; Randomize the pcolor with the term "one-of"
  ]
  ]
set-default-shape mafious "mafious"                                        ; In the turtle shape editor we have defined a shape called mafious
create-mafious initial-number-mafious                                      ; Lets us adjust the initial number of mafious by a slider
[
  set color black
  set size 2
  set money initial-money-mafious                                          ; Nå som slider 
  setxy random-xcor random-ycor                                            ; En reporter
  
]

set-default-shape cops "cops"
create-cops initial-number-cops
[
  set color blue
  set size 2
  set money initial-money-cops
  setxy random-xcor random-ycor
]

set-default-shape storeowners "storeowner"
create-storeowners initial-number-storeowner
[
  set color white
  set size 2
  set money initial-money-storeowners
  setxy random-xcor random-ycor]

set endowment count patches with [pcolor = green]                                   ; Endowment er generert profitt som simulerer tidligere markedsdynamikk og som representerer profitt.
reset-ticks                                                                         ; Fargen på disse feltene er grønn. Når en storeowner genererer profitt vil patcen bli rød.
end 

to go
    if not any? turtles [ stop ]                          ; Spørsmålstegn fordi det er en logisk variabel. stop er en Netlogo commando.                                    
  ask storeowners [
    take-money
    multiply-storeowner                                   ; reproduce the storeowners turtles, as they get profits.
    move
    death
         ]
  ask mafious [
    move
    catch-storeowners                                     ; the mafious asks for the pizo to a storeowner. En storeowner spør etter en sum penger av storeowners. 
    death                                                 ; Gevinst er bedre 
  ]
    ask cops [
    move
    catch-mafious                                         ; the cop ask a bribe for don't arrest the mafious.
    ]

  if endowment? [ ask patches [ endowment-return ] ]
  set endowment count patches with [pcolor = green]
  tick
end 

to move 
  rt random 50
  lt random 50
  fd 1
end 

to take-money  
  if pcolor = green [
    set pcolor red
    set money money + 5
  ]
end 

to catch-storeowners
  let mafia-power sum ([money] of mafious in-radius 20) / 100  ;  We define the local variable mafia-power: the more rich the mafious are in a radius of 10, the bigger its influence 
                                                                                                     ; is in that area.
  let ProbRefuse-myself sum ([money] of cops in-radius 20) / 100             ; Vi definerer Probrefuse-myself som tilhører storeowners som en funksjon som er avhengig av politiets ressurser 
                                                                             ; i nærheten. (Radius 10). Sannsynligheten for å betale mafiaen penger.                   
                                                                                                   
  let prey one-of storeowners-here                   
  if prey != nobody                                                          ; Hvis bytte(storeowner) er forskjellig fra ingen gjør følgende
  [ask prey [ifelse (((ProbRefuse-myself  * ((storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 ))) < mafia-power )
      
     ;  Storeowners(prey): Hvis summen av politiets ressurser i nærheten og 
     ; (Probrefuse) sannsynligheten for å ikke betale mafiaen (Innstilt med slider) multiplisert med politiets-styrker (innstit med slider)/100 /1000 er mindre enn mafians ressurser
     ; som representerer inflytelse i det området (mafia-power)   Hvis sant: prey(storeowner) betaler tre penger til mafian. Gevinst: Vekst i profitt i nærliggende område vil øke (endowment)
     ;                                                            Hvis falskt: Storeowner mister en pengeenhet som følge av mafiaens undertrykkelse.
     
           [set money money - 3 ask patches in-radius 5 [endowment-return]] [set money money - 1 ask patches in-radius 2 [stop endowment-return]]]]
  ifelse (((ProbRefuse-myself * ((storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 ))) < mafia-power )
 [set money money + 3] [set money money + 0]                     ; The mafious obtain 3 coins if the storeowner pays, and anything if the storeowner refuses to pay. The police-power variable
end                                                               ; is a coefficient that can turns negative, in the case in wich the police helps the mafious.

to catch-mafious
  let payment sum ([money] of mafious-here)                      ; Definerer payment som bestikkelsen en mafious må betale til en politi-agent. payment would be the bribe paid by the mafious to the cop turtle.
  let prey one-of mafious-here                                   ; Byttet er nå en random mafia-agent
  if prey != nobody
  [ask prey [ifelse (storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 > 0 [set money money - (((storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 / 100) * payment)] [set money money + (((storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 / 1000) * payment)]]] 
  
  ; Hvis politiets makt er større enn null så vil en mafious betale politiet og avhengig av payment(bestikkelse) multiplisert med politiets innflytelse/100
  ; Hvis politiets makt ikke er større enn null, i tilfellet hvis politiet samarbeider med mafiaen,
  ; så vil mafiaen få et friere spillerom av politiet, noe som vil øke mafiaens inflytelse og formue.
  
  ifelse (storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 > 0 [set money money + ((storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 / 100) * payment] 
  [set money money + ((storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 / 1000) * payment]                              ; If the police decides to go against the mafious, its bribe is bigger than
                                                                                   ; if it decides to help the mafious in domaining the market.
end 

to endowment-return                 ; Definerer veksten i profitt. Instilles ved hjelp av en slider.                                        defines the regrowth of the patch of endowment.
  if pcolor = red [                 ; Hvis patch er rød(Ikke noe profitt å hente)
    ifelse countdown <= 0                         ; Hvis countdown er mindre eller lik null gjør fargen om til grønn (profitt) og sett nedtelling lik endowment-rate som justeres med slider.
    [set pcolor green
      set countdown endowment-rate ]           ; endowment-rate is the control of the "growt" of profits in the market. Man kan instille hvor kjapt profitten skal endres.
   [set countdown countdown - 1 ]              ; Hvis ikke countdown er mindre eller lik null, sett trekk ifra en pengeenhet.
  ]
end 

to death
  if money < 0 [die]                   ; Variabel som tilhører mafia og storeowner. Forsvinner ut av markedet dersom de ikke har penger.
end 

to multiply-storeowner
     let mafia-power sum ([money] of mafious in-radius 10) / 1000
    if money > 10 and random-float 100 < storeowners-multiply                                                  
    
    ; a storeowner just will expand its business if it has the
    ; sufficient money, if the power of police linked with the global probability of refusal to pay the pizo would be bigger than the
    ; the power of mafia (it means that the presence of mafia may reduce the willingness of new people to join in the market).
    ; storeowners-multiply is a slider wich can control the reproduction of the storeowner turtle.
    
    and ((storeowners-thrust-in-govs-ability-to-fight-mafia * police-power) / 2 / 100) > mafia-power  
    [hatch 1 rt random-float 360 fd 1 
      let ProbRefuse-myself sum ([money] of cops in-radius 10) / 1000] ; the new hatches of storeowners are born with the endogenous probability of refusal
    ;to pay the piso.
  set money (money / 1.5)
end 

; Copyright: Adrian Ordemann and
; Benedito Faustinoni

There is only one version of this model, created almost 11 years ago by Benedito Neto.

Attached files

File Type Description Last updated
Mafia Model.png preview Preview for 'Mafia Model' almost 11 years ago, by Benedito Neto Download

This model does not have any ancestors.

This model does not have any descendants.