Its an elevator problem. An elevator will know which floor it is on and which floor it is on the way to and which direction it is (Up, Down or Still). The elevator will "work" with another elevator and determine who should get a person that wants to go from a particular floor according to the following principle: If both elevators are still, the closest elevator to the person should move, else the elevator that is not moving should move and when both are in motion do nothing. The lift should also have a function which increments the state ie. increases the floor if the direction is up and decreases when it is down.
I hope you understand!