made set_r() output 3d numpy array instead of list
optimized get_next_generation() method