<s> from Schelling import SchellingModel <EOL> from mesa . visualization . ModularVisualization import ModularServer <EOL> from mesa . visualization . modules import CanvasGrid , ChartModule , TextElement <EOL> class HappyElement ( TextElement ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self ) : <EOL> pass <EOL> def render ( self , model ) : <EOL> return "<STR_LIT>" + str ( model . happy ) <EOL> def schelling_draw ( agent ) : <EOL> '''<STR_LIT>''' <EOL> if agent is None : <EOL> return <EOL> portrayal = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:r>" : <NUM_LIT:0.5> , "<STR_LIT>" : "<STR_LIT:true>" , "<STR_LIT>" : <NUM_LIT:0> } <EOL> if agent . type == <NUM_LIT:0> : <EOL> portrayal [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> else : <EOL> portrayal [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> return portrayal <EOL> happy_element = HappyElement ( ) <EOL> canvas_element = CanvasGrid ( schelling_draw , <NUM_LIT:20> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> ) <EOL> happy_chart = ChartModule ( [ { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ] ) <EOL> server = ModularServer ( SchellingModel , <EOL> [ canvas_element , happy_element , happy_chart ] , <EOL> "<STR_LIT>" , <NUM_LIT:20> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:4> ) <EOL> server . launch ( ) </s>
