#NEWLINE# def step( self , model ) : #NEWLINE# #INDENT# "\n        Determines the agent opinion for the next step by polling its neighbors\n        The opinion is determined by the majority of the 8 neighbors' opinion\n        A choice is made at random in case of a tie\n        The next state is stored until all cells have been polled\n        " #NEWLINE# neighbors_opinion = Counter ( ( n . get_state ( ) for n in model . grid . neighbor_iter ( ( self . _col , self . _row ) , True ) ) ) #NEWLINE# polled_opinions = neighbors_opinion . most_common ( ) #NEWLINE# tied_opinions = [ ] #NEWLINE# for neighbor in polled_opinions : #NEWLINE# #INDENT# if ( neighbor [ 1 ] == polled_opinions [ 0 ] [ 1 ] ) : #NEWLINE# #INDENT# tied_opinions . append ( neighbor ) #NEWLINE# #UNINDENT# #UNINDENT# self . _next_state = random . choice ( tied_opinions ) [ 0 ]