#NEWLINE# def cgol_draw( cell ) : #NEWLINE# #INDENT# '\n    This function is registered with the visualization server to be called\n    each tick to indicate how to draw the cell in its current state.\n    :param cell:  the cell in the simulation\n    :return: the portrayal dictionary.\n    ' #NEWLINE# assert ( cell is not None ) #NEWLINE# portrayal = { #NEWLINE# #INDENT# 'Shape' : 'rect' , #NEWLINE# 'w' : 1 , #NEWLINE# 'h' : 1 , #NEWLINE# 'Filled' : 'true' , #NEWLINE# 'Layer' : 0 , #NEWLINE# #UNINDENT# } #NEWLINE# ( x , y ) = ( cell . getX ( ) , cell . getY ( ) ) #NEWLINE# portrayal [ 'x' ] = x #NEWLINE# portrayal [ 'y' ] = y #NEWLINE# colors = { #NEWLINE# #INDENT# CGoLCell . DEAD : 'white' , #NEWLINE# CGoLCell . ALIVE : 'black' , #NEWLINE# #UNINDENT# } #NEWLINE# portrayal [ 'Color' ] = colors [ cell . getState ( ) ] #NEWLINE# return portrayal