Claudio Rivoira

Simulation models for economics

Project work on

"Football supporters."

 

The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.


powered by NetLogo

view/download model file: football_supporters.nlogo

WHAT IS IT?

The model shows the number of people that follow the match of the local football team in their town/city. Adults live their life moving in the city. They can influence and they can be influenced by the people that they meet during the week and on sunday they decide to go or not to go to the stadium.


HOW IT WORKS

In this simulation, the world is divided in 2 parts: the blue one is the real world and the green one rappresent the stadium.


HOW TO USE IT

The first procedure is Setup: it creates the stadium (green) and the world (blue).
A number of adults equal to the value of the dimension of the city (big, medium or small).
Click the button go to start the simulation.
The user have to choose also the size of the city, the league and the team tickets policy.
The button News means that the team buy a new important person for the list.
The plot happy and sad shows how many people are happy or not
The plot stadium regards the people that, on sunday, they go to the stadium.
The plot balance shows if the team is in active or not.
The plot result shows the last team result and the trend (2 means a victory, 1 a draw and 0 a match lost).


THINGS TO TRY

Itís interesting to edit the values of the sliders in order to compare the different behaviours of the people in different cities and in different leagues.


EXTENDING THE MODEL

It possible also to study a new agent: the sponsors are an important value for the football team balance.


PROCEDURES

breed [ adults adult ] 
globals [ Days fedelity_league a b result balance c ]
turtles-own [ fedelity]


to setup 
  ca 
ask patches with [pycor > 0] [set pcolor green]
ask patches with [pycor <= 0] [set pcolor blue]

set-default-shape adults "person"
if League = "League A" [set fedelity_league 50]
if League = "League B" [set fedelity_league 40]
if League = "League C" [set fedelity_league 30]
if League = "League D" [set fedelity_league 20]

if City = "Big" [create-ordered-adults 1000]                    
if City = "Medium" [create-ordered-adults 500]
if City = "Small" [create-ordered-adults 100]
  
  
set Days 0
set result "play"

ask adults [
      setxy (random 30) (random -15)
      if (ycor = 0) [set ycor (ycor - 1)]
      set color ((random 10) + 10)
      set a (random 100)
      if a <= fedelity_league [set fedelity "yes"]
      if a > fedelity_league [set fedelity "no"]    
       ]
set balance ( count adults with [fedelity = "yes"] * Tickets_Price * 0.75)
ask adults [if color > 19.9 [set color 19.9]]
ask adults [if color < 10 [set color 10]]


end


to go
  ask adults [forward 0.2
  if ycor > 0 [set ycor (ycor - 15)]    
  if ycor < -15 [set ycor (ycor + 15)]]
  
  
  ask adults with [ color > 15 ]
      [ask adults in-radius 0.5[ if (color < 19.9 ) [set color (color + 0.2)]]]
      
  ask adults with [ color < 15 ]
      [ask adults in-radius 0.5 [ if (color > 10 ) [set color (color - 0.2)]]]
 
  ask adults [if color > 19.9 [set color 19.9]]
  ask adults [if color < 10 [set color 10]]
  
  if Tickets_Price <= 15 [ask adults with [fedelity = "no"] [set color (color + 0.1)]]
  if Tickets_Price >= 20 [ask adults with [fedelity = "no"] [set color (color - 0.1)]]
  ask adults [if color > 19.9 [set color 19.9]]
  ask adults [if color < 10 [set color 10]]

   
   
  
set Days (Days + 1)
  
if Days mod 7 = 0 [Sunday] 
do-plots1 
if Days mod 7 = 0 [do-plots2]  


end
 

to Sunday 
    
  ask adults with [fedelity = "yes"] [setxy (random 30) (random 15)
    if (ycor = 0) [set ycor (ycor + 1)]]
  ask adults with [color >= 15] [setxy (random 30) (random 15)
    if (ycor = 0) [set ycor (ycor + 1)]]
  
  
                                             
                                                                           
  set b (random 3)
  if b = 0 [set result "L"]
  if b = 1 [set result "D"]
  if b = 2 [set result "W"]
  ask adults [if (result = "W")[ if ( ycor > 0) [set color (color + 2)]
                                if (ycor < 0) [set color (color + 1)]]]
  ask adults [if (result = "L")[ if ( ycor > 0) [set color (color - 2)]
                                if (ycor < 0) [set color (color - 1)]]]
  
  ask adults [if color > 19.9 [set color 19.9]]
  ask adults [if color < 10 [set color 10]]
  
  ask adults [if (ycor > 0)[if (result = "W") [ask adults in-radius 0.5 [if (color > 10) [set color (color + 0.2)]]]]]
  ask adults [if (ycor > 0)[if (result = "L") [ask adults in-radius 0.5 [if (color < 19.9) [set color (color - 0.2)]]]]]
  ask adults [if color > 19.9 [set color 19.9]]
  ask adults [if color < 10 [set color 10]]
  
  
  set balance (balance + (count adults with [ycor > 0] * Tickets_Price))
  if (result = "W") [set balance (balance + (count adults) + (count adults with [ycor > 0]* 2))]
  if (result = "L") [set balance  ( balance - ((count adults) * Tickets_Price))]


  ask adults [if color > 19.9 [set color 19.9]]
  ask adults [if color < 10 [set color 10]]
  
  do-plots3
  do-plots4
end
 
 
to News+
 
  ask adults with [color < 19.9 ][ set color (color + 2)]
  ask adults [if color > 19.9 [set color 19.9]]
  
end

to News-
  ask adults with [color > 10 ][ set color (color - 2)]
  ask adults [if color < 10 [set color 10]]

end


to Capital-Loss
  set c (random 50)
  if c > 0 [set balance (balance - (c))]
  if c > 0 [ask adults with [fedelity = "no"] [set color (color - 5)]]
  ask adults [if color < 10 [set color 10]]
    
end

to Capital-Gain
  set c (random 50)
  if c > 0 [set balance (balance + (c))]
  if c > 0 [ask adults with [fedelity = "no"] [set color (color + 5)]]
  ask adults [if color > 19.9 [set color 19.9]]
end


to do-plots1
  
  set-current-plot "happy and sad"
  set-current-plot-pen "happy"
  plot  count ( adults with [ color >= 15 ])
  set-current-plot-pen "sad"
 plot count ( adults with [ color < 15 ] )
end

to do-plots2
  set-current-plot "stadium"
  set-current-plot-pen "total"
  plot  count ( adults )
  set-current-plot-pen "people_stadium"
 plot count ( adults with [ ycor > 0 ] )
end 


to do-plots3
  
  set-current-plot "balance"
  set-current-plot-pen "balance"
  plot  balance
  
end

to do-plots4
  
  set-current-plot "result"
  set-current-plot-pen "result"
  plot  b
end