generic game of life algorithm implementation in javascript