Start the app with ruby sim.rb
Simulate a Building
with Elevators
, Floors
, and People
.
The Simulation
class runs on repeated iterations we call clock_ticks
, where in every iteration, the program simulates a Building
in which People
want to get to different Floors
using Elevators
. Simulation
creates the Building
and the agents that comprise it.
The Building
holds a collection of Floors
and Elevators
, and it also manages the task of making a call to an Elevator
from a specific Floor
. At every iteration of clock_tick
the Building
send a clock_tick
command to all the elevators
.
The Floor
holds a queue of People
that are waiting to board a passing Elevator
. The Floor
class makes the elevator calls for the People
to the Building
which holds the collection of Elevators
.
The Elevator
holds a list of Passangers
and is travelling :up and :down the Building
. The Elevator
can determine what elevator calls it is getting in order to travel to the Floors
that have People
queueing in them. When the Elevator
has no passengers and there were no elevator calls made, the Elevator
travels to the resting_floor
.
- In order to change the current configuration (1
Elevator
, 5Floors
, 5Simulations
) please change them insim.rb
. - People are created randomly as the
Simulation
continues (at a %50 chance). - The
Elevator
class ques the elevator calls and determines which ones it should answer in a first-come-first-served basis, while travelling up and down, stopping once at every floor for everyclock_tick
.
As of the most recent build the Simulation
class can only simulate one elevator in a building, but as many floors
, people
, and simulations
as you want.