write simulation engine