Exemple #1
0
 def plot_behavior_payoff(self, results, imageFilePath):
     """Plots a graph that depicts the behavior and the
     payoff of the players/agents from 'results' to one
     or more image files, taking 'imageFilePath' as base name.
     """        
     plotter = Plotter(imageFilePath, self.image_file_types, "right")
     plotter.beginDoublePlot("Period", 
             "Percentage in total subject population", 
             "Payoffs in MUs", 
             (0, self.chronicles.world.maxRounds), 
             (0,100), (30,60))    
     data = PC([results[FREE_RIDERS], results[HIGH_CONTRIBUTORS]])
     plotter.barPlot([FREE_RIDERS, HIGH_CONTRIBUTORS], data, yaxis = "left")               
     plotter.linePlot([PAYOFF_HC], [results[PAYOFF_HC]], yaxis = "right")
     plotter.linePlot([PAYOFF_FR], [results[PAYOFF_FR]], yaxis = "right")
     plotter.endPlot()
Exemple #2
0
 def plot_choice_contrib(self, results, imageFilePath):
     """Plots a graph that depcits the institution choice and the
     contributions of the players/agents from 'results' to one
     or more image files, taking 'imageFilePath' as base name.
     """
     plotter = Plotter(imageFilePath, self.image_file_types, "right")
     plotter.beginDoublePlot("Period",
             "Percentage in total subject population", 
             "Contribution in percent of endowment", 
             (0, self.chronicles.world.maxRounds), 
             (0,100), (0,100))    
     data = PC([results[SI_MEMBERS], results[SFI_MEMBERS]])
     plotter.barPlot([SI_MEMBERS, SFI_MEMBERS], data, yaxis = "left")               
     plotter.linePlot([AV_CONTRIB_SI], PC([results[AV_CONTRIB_SI]]), yaxis = "right")
     plotter.linePlot([AV_CONTRIB_SFI], PC([results[AV_CONTRIB_SFI]]), yaxis = "right")
     plotter.endPlot()
Exemple #3
0
 def plot_agent_payoff(self, stats, imageFilePath, deviation = None):
     """Plots the agent statistics for either a single agent or for a group
     of agents."""
     plotter = Plotter(imageFilePath, self.image_file_types, "right")        
     plotter.beginDoublePlot("Period", 
             "Percentage total agent class", 
             "Payoffs in MUs", 
             (0, self.chronicles.world.maxRounds), 
             (0,100), None)
     data = PC([stats[AG_SI], stats[AG_SFI]])
     plotter.barPlot([AG_SI, AG_SFI], data, yaxis = "left")
     if deviation: 
         error = deviation[AG_PAYOFF]
     else:
         error = None
     plotter.linePlot([AG_PAYOFF], stats[AG_PAYOFF], error , "right")
     plotter.endPlot()
Exemple #4
0
 def plot_payoff_punishment(self, results, imageFilePath):
     """Plots a graph that depicts the payoff and number of punishers
     and non-punishers from the 'results' to one or more image files
     at 'imageFilePath'.
     """    
     plotter = Plotter(imageFilePath, self.image_file_types, "right",
                       condense_factor = 5)
     plotter.beginDoublePlot("Periods", 
             "Percentage of high contributers in SI", 
             "Payoffs in MUs", 
             (0, self.chronicles.world.maxRounds), 
             (0,100), (30,60))
     data = PC([results[PUNISH_HC], results[NO_PUNISH_HC]])
     plotter.barPlot([PUNISH_HC, NO_PUNISH_HC], data, yaxis = "left")        
     plotter.linePlot([PAYOFF_NOP_HC], [results[PAYOFF_NOP_HC]], yaxis = "right")            
     plotter.linePlot([PAYOFF_P_HC], [results[PAYOFF_P_HC]], yaxis = "right")
     plotter.endPlot()
Exemple #5
0
 def plot_agent_contrib(self, stats, imageFilePath, deviation = None):
     """Plots the contributions, sanctions and received punishements
     or commendations of an agent."""
     plotter = Plotter(imageFilePath, self.image_file_types, "right")
     plotter.beginDoublePlot("Period",
             "Coercions received", 
             "Contribs/Sanctions in percent of endowment", 
             (0, self.chronicles.world.maxRounds), 
             None, (0,100))
     if deviation:
         error = [deviation[AG_PUNISH], deviation[AG_COMMEND]]
     else:
         error = None   
     plotter.barPlot([AG_PUNISH, AG_COMMEND],
                     [stats[AG_PUNISH], stats[AG_COMMEND]],
                     errorBars = None, yaxis = "left") # graph gets too confusiung if errorBars are plotted here
     if deviation:
         error = PC([deviation[AG_CONTRIB], deviation[AG_SANCT]])
     else:
         error = None
     plotter.linePlot([AG_CONTRIB, AG_SANCT], 
                      PC([stats[AG_CONTRIB], stats[AG_SANCT]]), 
                      errorBars = error, yaxis = "right")
     plotter.endPlot()