Implementation of Tom Shellings seggregation model in javascript