simulation algorithm