Programming Discrete Simulations