-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.c
34 lines (27 loc) · 1005 Bytes
/
util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Created by Charumathi Badrinath */
#include <stdio.h>
/**
* A temporary array that the threeWayIntersection() and fourWayIntersection() methods will be working on. It is
* cleared by the clearRoads() function immediately after it's contents have been translated into roadsArray[]
**/
road outgoingRoads[5] = {0, 0, 0, 0, 0};
/**
* Counter variable which is incremented every time a given traffic flow causes cars to either merge or cross paths.
* This counter is reset after every cycle of DFS through the implicit tree
**/
int conflicts = 0;
short roadsArray[NUM_ROADS * BIDIRECTIONAL];
void printRoads () {
for (int i = 0; i < 38; i++) {
printf ("%i", roadsArray[i]);
}
puts (" ");
return;
}
/* Initializes the values of roads (number of roads * number of lanes) to unused at the start of the program */
void initialiseRoadArray (int noOfRoads, int lanes, short roads[]) {
for (int i = 0; i < lanes * noOfRoads; i++) {
roads[i] = 0;
}
return;
}