Here's the code we wrote for our final project:

 

 

to touch1

output (switch 7)

end

to touch2

output (switch 8)

end

to touch3

output (switch 9)

end

to motor1

a,

end

to motor2

b,

end

to motor3

c,

end

to motor4

d,

end

to sensor1

ifelse ((sensor 0) > 70)
[output 0]
[output 1]

end

to sensor2

ifelse ((sensor 1) > 70)
[output 0]
[output 1]

end

to sensor3

ifelse ((sensor 2) > 70)
[output 0]
[output 1]

end

to points

loop [waituntil [or touch1 (or touch2 touch3)]
motor4 setpower 3.5 on
waituntil [or sensor1 (or sensor2
sensor3)]
if (sensor1) [when [(not
sensor1)] [motor4 off]]
if (sensor2) [when [(not
sensor2)] [motor4 off]]
if (sensor3) [when [(not
sensor3)] [motor4 off]]
]

end

to board

launch [points]
launch [if sensor3 [ab, on thisway c, on thisway
wait 10
ab, off c, off
ab, on thatway c, on thatway wait 10
ab, off c, off]]
cars

end

to cars

loop [if touch1 [motor1 on thisway onfor 10
motor1 on thatway onfor
10]
if touch2 [motor2 on thisway onfor 10
motor2 on thatway onfor
10]
if touch3 [motor3 on thisway onfor 10
motor3 on thatway onfor
10]]

end