-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasics.py
More file actions
48 lines (35 loc) · 1.19 KB
/
Copy pathbasics.py
File metadata and controls
48 lines (35 loc) · 1.19 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Artificial Intelligence Fall 2016
Final Project: NeverRed
Authors: Alex Gribov and Donovyn Pickler
File: trafficAgents.py
This file is entirely the work of the authors
"""
from util import *
import sys
class TrafficAgent:
def __init__(self):
util.raiseNotDefined()
def getAction(self, state):
util.raiseNotDefined()
class TrafficState:
def __init__(self, traciObj, n = 4):
self.traciData = traciObj
self.numLanes = n
self.vehicles = []
for i in range(1,n+1):
self.vehicles.append(self.traciData.multientryexit.getLastStepVehicleIDs(numToLane(i)))
def getNumHalted(self, laneNum):
return self.traciData.multientryexit.getLastStepHaltingNumber(numToLane(laneNum))
def getNumCars(self, laneNum):
return self.traciData.multientryexit.getLastStepVehicleNumber(numToLane(laneNum))
def getVehicleList(self, laneNum):
#print laneNum
#print self.vehicles
return self.vehicles[laneNum-1]
def getLightState(self):
return self.traciData.trafficlights.getPhase("0")
def setLightState(self, nextState):
return 0
def traci(self):
return self.traciData