Ruby elevator simulator program

Develop a simulation of an elevator that travels between floors 1 and N where N is an input. Time is sequenced in discrete steps starting at 1; at each time step, the elevator may ascend one floor, descend one floor, or remain at its current floor, as determined by its strategy. The first line of the input file indicates the number N of floors. This is followed by one line per person using the elevator: her id, call time (when she calls for the elevator), origin floor (where she boards the elevator), and destination floor (where she debarks the elevator). For example:


100 2 1 4

101 3 4 5

102 3 3 2

103 5 5 1

104 5 1 4

Here, individual 100 boards at time 2 from floor 1 with a destination of floor 4. Assume sensible inputs (e.g., times are positive integers, floors are integers in the range 1 through N).

Whenever the elevator stops at a floor from which people have called it (i.e., their origin floor but not before their call time), they all board the elevator. And whenever the elevator stops at any passengers’ destination floor, they all get off the elevator. (Everyone behaves so as to minimize their travel time.) The simulation stops when every passenger has been brought to his or her destination floor (subject of course to their call time and origin floor constraints).

A strategy determines the floor the elevator begins on at time 1, and a policy for moving to the next floor (up one floor, down one floor, or remaining at the current floor) from one time step to the next. These are implemented by its intial_floor and next_floor policy methods. A strategy is notified whenever a person calls it (person_calls method), when a passenger boards (person_gets_on), and when a passenger debarks (person_gets_off). Information provided through these last three notification methods can be used to tailor an intelligent strategy for moving from floor to floor.

class Strategy

def initial_floor


def next_floor


def person_calls(time, from)


def person_gets_on(time, from, to)


def person_gets_off(time, to)

end end

Here is a naïve strategy that does not make use of the information supplied by the notification methods:

Strategy 1: Start at floor 1. In each time step, successively go up one floor until reaching the top floor N, then successively go down one floor until reaching the bottom floor 1, and continue this ‘up to the top floor then down to the bottom floor’ policy.

Here we run the simulation using the input file [login to view URL] (given above) and Strategy 1:

Beceriler: Ruby, Ruby on Rails

Daha fazlasını gör: atm simulator program, keystroke simulator program, write simulator program, elevator simulator project java, simulator program, java elevator simulator, 8085 simulator program, win32 mouse keyboard simulator program, program develop game bejeweled, training program develop, simulator program csma, smpp simulator program, cpu simulator program, java elevator control program, program develop process simulation, loyalty program develop freelancer, traffic lights simulator program, drink machine simulator program, cpu scheduling simulator program, multiple elevator simulator code

İşveren Hakkında:
( 0 değerlendirme ) Romania

Proje NO: #28411155

Bu iş için 1 freelancer ortalamada $250 teklif veriyor


Hello! I am bidding on the project regarding Ruby elevator simulator program I have read your project description carefully. I am software developer and programmer have 7 years experience in it. I have few questions. I Daha Fazla

$250 USD in 12 gün içinde
(0 Değerlendirme)