Build a Horse Race Simulator using C++, SFML & a Skip List

Lesson 7 of 7

Final Project: Finish Your Horse Race Simulator

Every piece is built: a skip list that stays correctly sorted as keys change, a track and horses drawn with SFML, a race loop that keeps the two in sync every frame, a live leaderboard, and finish-line detection. Combine them into one complete, playable simulator.

Requirements

  1. Run at least 6 horses simultaneously, each in its own lane, each advancing by an independent random amount every tick.
  2. Every horse's movement must go through erase + insert on the skip list, exactly like the race loop lesson, no shortcuts that bypass the skip list to fake the leaderboard.
  3. Display a live leaderboard (built from track.leaderboard()) that updates every frame while the race is running.
  4. Detect the finish line and freeze the race the instant a horse crosses it, showing a clear "Horse N wins!" message.
  5. Add a "Press SPACE to restart" flow that resets every horse's distance to 0, rebuilds the skip list from scratch, and starts a new race without closing the window.

Stretch goals

  • Give each horse a "stamina" stat that shifts its random speed range over the course of the race (e.g. a burst early, a slower stretch mid-race), instead of every horse pulling from the exact same range the whole time.
  • Handle a genuine photo finish: if two or more horses cross FINISH_LINE within the same frame, compare their exact distance values (not just loop order) to pick the real winner.
  • Add a small debug overlay that draws each skip list level as its own row of dots, one per node present at that level, so you can see the express lanes thin out as you go up, exactly like the diagram from the first lesson.
  • Track and display each horse's best-ever finishing time across multiple races in the same session.

Submit a link to your finished project (a repo or gist) below, an instructor will review it before you can mark this lesson complete. Good luck! 🚀

This lesson ends in a project. Build it on your own machine, there's nowhere to submit it here, but the brief above is everything you need.