Skip to content

A simulation of traffic in an intersection. The traffic lights are designated (N, S) and (E, W) like a compass.

Notifications You must be signed in to change notification settings

warrenca/traffic-lights-simulation

Folders and files

NameName
Last commit message
Last commit date
Feb 25, 2018
Feb 25, 2018
Feb 25, 2018
Jul 21, 2017
Jul 20, 2017
Feb 25, 2018
Jul 21, 2017
Jul 21, 2017
Jul 21, 2017
Jul 21, 2017
Feb 25, 2018
Jul 20, 2017

Repository files navigation

Traffic Stop Lights Simulation

A simulation of traffic in an intersection. The traffic lights are designated (N, S) and (E, W) like a compass.

Assumptions

  • When switching from green to red, the yellow light must be displayed for 30 seconds prior to it switching to red.
  • The lights will change automatically every 5 minutes.
  • Provide the output for the light changes which occur during a given thirty minute period.

Install

$ npm install

Run in command line

$ npm start

⚡ npm start

> [email protected] start
> babel-node src/index.js

Sun Feb 25 2018 23:34:26 GMT+1300 (NZDT) The program will run for 110s
Sun Feb 25 2018 23:34:26 GMT+1300 (NZDT) Start!
Sun Feb 25 2018 23:34:26 GMT+1300 (NZDT) All lights are red
Sun Feb 25 2018 23:34:26 GMT+1300 (NZDT) {"NS":"green","NE":"green","SN":"green","SW":"green"}
Sun Feb 25 2018 23:34:33 GMT+1300 (NZDT) {"NS":"orange","NE":"orange","SN":"orange","SW":"orange"}

Run website

Simply open the index.html on a Chrome browser or do

$ npm run web

Run tests

$ npm test

Build project using webpack

Run this whenever there's a change in the code or config file

$ npm run webpack

** Note: For the interest of time, the compiled project has faster delays. It will run for a total of 110seconds, the green lights are on for 7seconds and the yellow lights are on for 4seconds.

About

A simulation of traffic in an intersection. The traffic lights are designated (N, S) and (E, W) like a compass.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages