# Lecture 21 - Projects, Trains

## Public Service Annoucements

1. Saturday November 5, 11.00 to 13.00. Open house for high school students.
2. Information session on graduate studies: Tuesday, 8 November, 2011 at 16.30 in MC 2065
3. First train control demo: 15 November, 2011.
4. Final exam: Friday, 9 December, 2011 at 09.30.

# Train Control Milestones

## 1. Tracking & Route Finding

What you are expected to do

• One locomotive on the track:
• Give the locomotive a speed at the terminal & set the direction of the time-outs at the terminal. You should be able to handle two scenarios.
1. Given stop command at a random time, you should know where the train is when it stops. `Where' means `x cm past switch/sensor y, travelling in direction z'
2. The part of the train from which measurements are made is the track contact, which is attached to one of the trucks. (The original definition of a truck is a unit consisting of several wheels, which supports part of a vehicle. Each locomotive locomotive has two four wheel trucks; an eighteen wheel semi-trailer has three trucks, a two wheel truck at the front of the tractor, an eight wheel truck at the back of the tractor, and a second eight wheel truck at the back of the trailer.)
• Your application knows where the train is at all times.
• `Where the train is' is defined above.
• Important terminology
• The velocity of a train is the rate at which it moves along the track, measured in centimetres/second. Velocity is normally signed, and the easiest way of doing the math is to make track segments directed
• The speed of a train is the number written to the train controller when you change how fast the train is going.
• The most important part of the first milestone is creating the ability to give a train a particular (integrated) velocity by altering its speed. This is called having a calibration of the train. (Integrated velocity is location.)
• This should be robust against one malfunctioning sensor or switch.
• To do this you need
• Calibration. Calibration is the primary goal of the first milestone.
• Route finding is part of this milestone only so that you can do things that show your calibration to be correct. For milestone 2 you will have to do route finding on track graphs with edges missing and with the train changing direction, so choose an approach to route finding that generalizes.
• It is possible to complete this assignment without achieving what you project needs simply by running the trains very slowly. We expect you to have the trains running fairly quickly -- speed 8 to 12 -- during the milestone demo.
• In the demo you can use your preferred train from among the working ones, and you can use your preferred track. But, your favourite train or your favourite track may not be working. In that case we expect you to run your demo using another train or track. Be prepared!

## 2. Avoiding

What you are expected to do

• Two or three locomotives on the track:
• Give each locomotive a destination & speed at the terminal.
• They find non-conflicting routes to their destinations and travel to them.
• Your application knows where the trains are at all times.
• This should be robust against malfunctioning sensors and switches
• Locomotives should not collide
• Locomotives should not fuse into one when they get too close together
• To do this you need
• A track reservation system

# Projects

## 1. Train style

Give trains roles and objectives. For example,

• Passenger train travels on a repetitive route meeting a schedule.
• Freight train travels to random destinations as fast as possible.
• Objective is to deliver as much freight as possible while keeping a passenger train on time.

Another example,

• Trains are like taxis.
• When a load appears they race to see which train gets it.

Another examples,

• Two or more trains are scheduled to run on routes that have sections of track in common.
• The have to keep their schedules.

Important Comment. Projects like these can vary from easy to hard, depending on things like how aggressive schedules are and how many trains are running on the track. You will probably want to start with unaggressive targets and increase the difficulty as a demo proceeds, so build your application accordingly.

## 2. Game style: AI

The track is a graph.

• Several different ways to choose vertices and edges

Many games are played on graphs

• Checkers, snakes & ladders, maze games, etc.
• Implement a graph game played on the track graph.

For example, watchmen and bandit.

• One train is the bandit, which tries to move from one hide-out to another.
• The other trains are watchmen, who try to prevent the bandit from getting to a hide-out once he is out in the open.

Another example, PAC man

• One train tries to cover as much track as possible.
• Other trains try to trap him so that he can't get reservations that would allow him to keep moving.

## 3. Game style: interactive

In the games you play for pleasure, the user normally controls one or more of the game entities.

• the bandit
• the trapping trains

Students often want to make an interactive project. It has been done successfully in the past, but constructing a usable interface is a challenge. Try starting with the project non-interactive: a not-very-intelligent artificial intelligence might, for example, stand in for the user in a partly functional version.