Code for election simulations