Sim Traffic Official Website

This is Sim Traffic official website. Developers and users can find source code, user and developer documentations, and bug list. Users or developers can also report bugs here.

Latest Updates

  • 06/03/09 1.0 Release
  • 05/29/09 Release Candidate Release
  • 05/22/09 Feature Complete Release
  • 05/15/09 Beta Release
  • 04/30/09 Zero Feature Release

User Documentation

Description

Sim Traffic is a puzzle game that simulates traffic situations. The users will manage the traffic and make sure that the number of cars that have waited for too long and that have crashed does not exceed the preset limit for each level within a certain time period. After the users complete a level, they can then proceed to the next level.

Unlike most of the traffic simulation software games out there, Sim Traffic is more similar to real-world traffic situations, and at the same time is not as complicated as the real traffic simulation software that the traffic planners use. The alternative softwares such as Traffic Control game or the real traffic simulation software are either too simple or too complicated to be interesting or too expensive to purchase.

Users want to use it because the software concept is unprecedented. Sim Traffic can be a brain twister for the users because managing traffic is intellectually challenging. Since each level is more difficult than the previous one, users get a sense of achievement every time they accomplish a level.

Obtain, Install, and Run the Software

  1. Go to http://cubist.cs.washington.edu/projects/09sp/cse403/traffic/
  2. Click download
  3. Click the latest version to download the .tar file
  4. Untar the file
  5. Go to src directory on the terminal and type "python main.py" (see note below)

You must get the following to run the software:

To run the software in Unix/Mac:

  1. Open the terminal window
  2. Then, using the "cd" command, go to your SimTraffic directory. For example, if your command prompt starts navigate in "/homes", and your SimTraffic directory is in "/homes/UserName/SimTrafficBeta", type in (without the outer quote): "cd "UserName\SimTrafficBeta\src"" in the terminal
  3. Then, type this command on the terminal window (without quote): "python main.py".

To run the software in Windows:

  1. Open the command prompt. You can open the command prompt by doing Start->Run->cmd (or Start->cmd in the "Start search" text box for Windows Vista). You can also go to Accesories->Command Prompt.
  2. Then, using the "cd" command, go to your SimTraffic directory. For example, if your command prompt starts navigate in "C:/", and your SimTraffic directory is in "C:\Users\UserName\Documents\SimTrafficBeta", type in (without the outer quote): "cd "Users\UserName\Documents\SimTrafficBeta\src"" in the command prompt
  3. Type this command on the command prompt (without quote): "set PATH=%PATH%;C:/Python26" (or other location in exchange of "C:/Python26" depending on where you install Python. Nonetheless, the default should be "C:/Python26".)
  4. Then, type this command on the command prompt (without quote): "python main.py".

User View

Sim Traffic is divided into levels of increasing difficulty. In each level, player needs to survive for a certain amount of time without having too many timed-out cars (cars that have waited too long or have collided with other car(s)). In other words, player has to keep traffic in control – not jammed around intersections. The time limit and the number of timed-out cars allowed vary among different levels. Typically, the higher the level, shorter time limit is given and less timed-out cars are allowed. Moreover, the map’s (road and traffic layout) complexity also increases as the level increases. Higher levels will involve larger maps, more vehicles, and more intersections.

In order to reach the objective of each level, players are able to place traffic signs on road intersections. There are two choices of traffic signs: stop sign and traffic light. While stop signs are just static traffic sign, traffic lights can be configured. Players can change the timers of the red and green light of every pair of traffic light. The challenge here is for player to decide which traffic signs to place on each intersection. Vehicles will respond to the stop signs by taking turn in order of their arrival at the intersection in proceeding through the intersection. On the other hand, traffic light’s red light and green light timers will be set by the user. Like in real-life traffic simulation, during red light, cars will stop and cars will have to yield if they want to turn right; during green light, cars that want to go straight or turn right will run like usual and if they will have to yield to turn left.

The major challenge of this game is analysis. In order to proceed to the next level, users will have to analyze each road's condition, whether it has low or high traffic, in a limited time. Based on their analysis, they will have to decide where to place the traffic signs; users also have to decide the red light and green light timers for each traffic light. For example, it is better to use stop signs instead of traffic lights to manage an intersection that has low traffic on its surrounding roads. Furthermore, after the simulation starts, users can do more analysis and make changes on the traffic signs, if desired. The road's condition, which is one of the most important parts to consider in the analysis, is determined by its color. Roads with darker color (dark grey) are roads with high traffic.

How to Play the Game

Once you run python main.py command, you will see the main menu. Click on the “Start Game” button to proceed to the level selection menu. Then you can choose a level you want using the right arrow or left arrow. The desired map will be shown in the middle. Note that you’ll have to accomplish a level before you can go on to the next level. Click “Start Game” to start playing. When the game starts, you can see timers on the bottom left. One is how much time you have left to set up your traffic signs in each direction, the other is how much time you have left after you start the simulation. To add or change the traffic signs, click on the intersection block then the prompt will guide you through adding or changing the signs. When you finish setting up or when setting up time is up, you will be in the simulation mode. You can still configure the traffic signs, such as removing, adding, or changing the timers for red light and green lights. To accomplish a game, you have to reduce the road rage to under the preset limit. This means that each car has a waiting timer, either for traffic jam or traffic signs. You want to make sure when the simulation time is up, the number of cars that are timed out (waiting too long) is less than the limit as shown on the bottom left corner of the screen, otherwise, you lose.

more detailed instruction

To add traffic signs, click on an intersection and choose the desired traffic sign (traffic light or stop sign) to be placed on from the component pop-up window.

To set the timer for traffic light, click on the corresponding traffic light, click on "Configure" button on the traffic sign window and insert the time interval for red and green light in the configuration pop-up window; before changing or setting timers, click on a traffic sign and its status will show up on the bottom right corner.

To replace traffic lights with stop signs and vice versa, by click on "Replace" button, which then will display a pop-up window of what kind of traffic sign you want to replace it with.

To remove traffic signs, click on "Remove" button and confirm it from configuration pop-up window.

Click here to view beginner tutorials

How to Report a Bug

Before reporting a bug, users can look up from the bug list to see whether the bug has been reported. This step can reduce the number of duplicate bug reports. Users can report a bug by filling out a form on the website - http://cubist.cs.washington.edu/projects/09sp/cse403/traffic/bug_report.html. The form has the following fields:

  • game version
  • operating system version
  • problem statement
  • steps to reproduce the bug
  • result
  • expected result.

Once the user submitted the form, the information will be entered to the database, which is available to view on the webpage - http://cubist.cs.washington.edu/projects/09sp/cse403/traffic/bug_report.html

Developer Documentation


Design Documentation

        Latest SDS
        Latest SRS


Obtain source code

  1. Go to our download link
  2. Download SimTraffic-0.1.tar.gz from that link
  3. Extract it to a folder (tar -xvf SimTraffic-0.1.tar.gz for UNIX/Linux)

You need to have python 2.6.2 and pygame library installed at your machine to run the software.

You can get :

To run the software in Unix, change directory to that folder and type this command on a shell (without quote) : “python main.py”

There is no database, so all necessary data is included in the source

Source Code Repository

Source code repository is located at:

svn+ssh://attu.cs.washington.edu/projects/instr/09sp/cse403/cse403f

You will need to get tortoise SVN to access the repository
http://tortoisesvn.net/downloads

To build the software from the repository, go to /Development/src/ folder and check out.
To run the software, follow the steps specified in "Obtain Source Code".

To package the source files, run the command "python setup.py sdist" in /cse403f/Developement directory

To release a new version

1. run the command "python setup.py sdist" in /cse403f/Developement directory
2. ssh to attu
3. Go to /projects/instr/cubist/09sp/cse403/traffic/ folder
4. Modify index.html and add the tarball to /projects/instr/cubist/09sp/cse403/traffic/download

Automated Test and Build

Running test suite

Currently, there are some test cases in the repository. To run the test suite, enter a command "./runtest.sh"

For test suite, we are going to use PyUnit (Python Test Unit). To make a unit test class, you need to import unittest, call setup(), and call some methods to check and report failures, if any. Furthermore, you will need to create a suite function where you create a test suite variable and set it. To run several unit tests from several files, you will need to make a test suite where you call all suite methods and run it. Here is the documentation of how to make a test suite:

http://docs.python.org/library/unittest.html

For example, you can refer to:

http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-unittest.html

Automate build and test

We are using cron to set up our daily build and test.
First, on a Unix machine, open /etc/crontab with your editor.
The inside of crontab will look something like this :

	SHELL=/bin/bash
	PATH=/sbin:/bin:/usr/sbin:/usr/bin
	MAILTO=root
	HOME=/
	# run-parts
	01 * * * * root run-parts /etc/cron.hourly
	02 4 * * * root run-parts /etc/cron.daily
	22 4 * * 0 root run-parts /etc/cron.weekly
	42 4 1 * * root run-parts /etc/cron.monthly
					

The first 4 lines are variable used to configure the environment in which the cron tasks are run.

The lines below #run-parts have the format:

Minute  Hour  Dayofmonth  Month  Dayofweek  User  Command

For example:

   “ 01 * * * * root run-parts /etc/cron.hourly “

This command (run-parts /etc/cron.hourly) is run at one min past every hour.
To get more information about how to use cron, follow this link:
http://unixgeeks.org/security/newbie/unix/cron-1.html
Now, you need to make or edit the crontab file to run your build and test scripts.

Steps

We will use cronic to wrap cron jobs so that cron only sends email when an error has occurred
  • Put cronic script in a directory
  • Write a build or test script and put it on the same directory as cronic
  • Edit or create a crontab file by typing "crontab -e" in your shell
  • Add these lines :

	SHELL=/bin/bash

	PATH=/sbin:/bin:/usr/sbin:/usr/bin

	MAILTO=root

	HOME=/
						
  • You can direct the report to desired email address by changing "root" to that email address
For example : if you want to send it to test@domain.com, you need to change "MAILTO=root" to "MAILTO=test@domain.com"
  • Add a new line in crontab
Assuming we store cronic and build.sh in path “/directory” and we want to run build.sh daily, the line will be:
01 0 * * * /directory/cronic    /directory/build.sh
This command ( /directory/cronic /directory/build.sh ) is run daily at 0:01 am.
  • Add additional lines in crontab for other scripts.
  • To make sure that any failure output is sent out to all developers, you need to change the parameter for MAILTO to cse403-traffic-planning@cs.washington.edu
MAILTO = cse403-traffic-planning@cs.washington.edu

NOTE: if you got "permission denied" error message, you need to change the permission for the scripts

You can use command "chmod +x <name of your script>"

Example:
chmod +x cronic
chmod +x build.sh

Layout of Directory Structure

1 Sim Traffic

           1.1 Development

                      1.1.1 media Folder - (contains sound and image files used for the software)

                      1.1.2 src Folder - (contains source code)

                      1.1.3 test Folder - (contains test code)

           1.2 Documentations - (contains documentations for users and developers)

           1.3 Website Folder - (contains all the files for the website)

           1.4 README.txt


List of Bugs

List of outstanding bugs and the list of resolved bugs can be viewd on the bug report webpage - http://cubist.cs.washington.edu/projects/09sp/cse403/traffic/bug_report.html. However, only selected developers (Traffic Simulation team) can edit the content of the list. Furthermore, every time changes made, all developers will be notified.

Valid XHTML 1.1 Valid CSS!