Second Trip makes Traffic scriptable. A scripting language is a programming language that is interpreted
or compiled every time it is run (see [login to view URL]).
What you must do, then, is to identify a certain subset of Traffic’s functionality (“API”) and make it
available through a scripting language. This means that you offer commands, corresponding to this
functionality, which a user can input into a scripting window and which Traffic will then execute. You are
free to choose the functionality - this will allow you to adapt this project to your programming experience.
Example functionality sets are:
• Adding vehicles, buildings, places, landmarks etc. to an existing map through scripting
• Building paths interactively
• A scriptable map editor (using commands the user can create his own map and save it in an xml)
If for instance you want to allow adding landmarks through scripts, an example Second Trip execution
could look like this:
> show_maps
1 Paris
2 Zurich_big
3 Zurich_small
> load_map 3
Zurich_small loaded
> set_image_dir C:/images
C:/images set as image directory
> new_landmark 100, 200, [login to view URL], “Hauptbahnhof”
landmark created
> new_landmark 50, 500, [login to view URL], “IFW”
landmark created
ETH Zürich: Introduction to programming – Exercises Prof. Dr. B. Meyer Fall 2007
Executing this script results in buildings being added to the Zurich_small map at locations (100,200) and
(50, 500). Note that the example script works in a shell-like way, interpreting one command at a time. You
could also choose to write your scripts into a text file and feed it to the program that will parse, check and
execute it.
This exercise leaves considerable freedom concerning the amount of work you invest. You may improve
and upgrade the functionality of your application to any extent you want. Feel free to use your
imagination! There are no limits. The main goal is to program and gain experience in extending large
systems