vitorarins / intersections

An application that simulates a set of traffic lights at an intersection.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table of Contents

intersections

This is a simple application, written in Golang, that simulates a set of traffic lights at an intersection.

The traffic lights are designated (N, S) and (E, W) like a compass.

Installation

If you have Go, go get it:

go get github.com/vitorarins/intersections

If you don't want to have Go installed on your system you can download the executable binary from the Releases page.

Just choose the latest version and click one of the Downloads links according to your Operating System. Currently there are versions for Linux, MacOS and Windows. All versions are for 64bit systems.

Running

After you've installed the intersections binary, you just have to run it. If it's in your PATH environment variable then you can just call it:

[user@pc]$ intersections

If it's not in your PATH then just give the full path of where you saved it:

[user@pc]$ ./path/to/intersections

Output

The output of this application is a set of strings showing the time the lights will change, starting at 00:00.00. Whenever the right time has passed, the lights changing event is reported.

Example:

(N, S): Green, (E, W): Red - 00:00.00
(N, S): Yellow, (E, W): Red - 04:30.00
(N, S): Red, (E, W): Green - 05:00.00
(N, S): Red, (E, W): Yellow - 09:30.00
(N, S): Green, (E, W): Red - 10:00.00

This goes on for 30 minutes.

Development

If you want to look and change the code, you can clone, build and run this repository:

[user@pc]$ git clone https://github.com/vitorarins/intersections.git
[user@pc]$ cd intersections
[user@pc]$ go build
[user@pc]$ ./intersections

The code was made trying to keep things simple and easy to change. So for example, if you want to change the time duration of color switching in the lights:

  • open main.go
  • change the colorDurations variable
  • go buildit again
  • run it again: ./intersections

About

An application that simulates a set of traffic lights at an intersection.

License:GNU General Public License v3.0


Languages

Language:Go 100.0%