cis441 project milestone 1a
Revision 3:aa2778d92301, committed 2019-11-11
- Comitter:
- mwgold
- Date:
- Mon Nov 11 01:33:28 2019 +0000
- Parent:
- 2:150dd9f9c0f1
- Commit message:
- final attempt
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 11 01:03:46 2019 +0000
+++ b/main.cpp Mon Nov 11 01:33:28 2019 +0000
@@ -18,6 +18,8 @@
Timer stopwatch; // A timer to keep track of how long the updates take, for statistics purposes
int numberCycles = 0;
int totalUpdateTime = 0;
+ int road1wait = 0;
+ int road2wait = 0;
// ------------------------------------------------------------------------------
int time = 0;
@@ -32,6 +34,20 @@
do {
intersection.preChecks();
+ if (intersection.queue[0] > -1) {
+ if (intersection.queue[0] < 5) {
+ road1wait++;
+ } else {
+ road2wait++;
+ }
+ }
+ if (intersection.queue[1] > -1) {
+ if (intersection.queue[1] < 5) {
+ road1wait++;
+ } else {
+ road2wait++;
+ }
+ }
int new_cars1 = road1->try_enter_car(time);
int new_cars2 = road2->try_enter_car(time);
@@ -91,6 +107,8 @@
// ----------------------------------------------------------------------
// Timing statistics printout, do not modify
printf("Average update cycle took: %fms \r\n", (totalUpdateTime*1.0)/(numberCycles*1.0));
+ printf("Average road1 intersection wait: %fs \r\n", (road1wait*1.0)/5.0);
+ printf("Average road2 intersection wait: %fs \r\n", (road2wait*1.0)/5.0);
totalUpdateTime = 0;
numberCycles = 0;
// ----------------------------------------------------------------------
