Home » Haques »
Scotland Yard





On its tenth birthday, I decided to resurrect a remarkable undergraduate C++ programming project. It was spring 1993, my sophomore year at Johns Hopkins. The course instructor was Mark Giuliano.

A group of five of us decided to implement a board game called Scotland Yard, where detectives try to track down a spy as he travels by bus, cab, and tube throughout the city of London. Some screen shots appear to the left. As you can see, they are full of check boxes, buttons, and dialogs.

What is most remarkable about this project is that we implemented it all on top of the very simple Borland Graphics Library for DOS+VGA. It supports drawing lines, circles, and the primitive text fonts you see. Beyond that, we rolled our own GUI toolkit!

For kicks, I ran all the source code through Doxygen (fantastic tool!), so you can browse it online. Here are pointers to some of the most interesting aspects:

  • Most GUI programming today is event-based. We defined our own Messages for keyboard events, mouse activity, button presses, etc.

  • A Display is a Viewport which can contain Screen Objects such as Windows and Buttons.

  • When the user clicks the mouse on the screen, the root display receives the event, and dispatches it to each of its children (all screen objects), in turn, until one acknowledges the event. Generally, a screen object determine whether they should handle the event based on its coordinates. Here is the dispatch routine for buttons.

  • We used multiple inheritance to model the players, since there are two kinds of players: spy and detectives, each of which can be controlled either by human or computer. (Better OO design patterns weren’t well publicized at the time!)

  • We defined an enum bool because the boolean type was not standard in C++ in those days! Probably several other modifications are necessary to compile our code with modern C++ tools.

As I recall, much of the initial design for the GUI stuff came to me in my dreams! I have rarely been so in the zone while programming as I was that semester, long ago.

Downloading Scotland Yard

This zip file (326k) contains the source code, map file, object code, and executable, exactly as we left them in April 1993. If you unzip this on a Windows PC, you should still be able to run the scotland.exe in a DOS box window.

Enhacing Scotland Yard

I would be tickled if someone were to port the game to use the Simple DirectMedia Layer (instead of the Borland Graphics Interface), so that it can run on Linux. Adding sound effects would be interesting too.
Scotland Yard appears to be a trademark of Ravensburger and Milton Bradley.

Published July 2003
Updated 25 July 2003