Doodlebug simulation in C++