Beispiel #1
0
    def noteCarMove(self, oldPos, newPos):
        oldRow, oldCol = util.yToRow(oldPos.y), util.xToCol(oldPos.x)
        newRow, newCol = util.yToRow(newPos.y), util.xToCol(newPos.x)
        oldTile = (oldRow, oldCol)
        newTile = (newRow, newCol)

        if oldTile in self.transitions:
            self.transitions[oldTile][newTile] += 1
        else:
            self.transitions[oldTile] = collections.Counter()
            self.transitions[oldTile][newTile] = 1
Beispiel #2
0
 def noteCarMove(self, oldPos, newPos):
     oldRow, oldCol = util.yToRow(oldPos.y), util.xToCol(oldPos.x)
     newRow, newCol = util.yToRow(newPos.y), util.xToCol(newPos.x)
     oldTile = (oldRow, oldCol)
     newTile = (newRow, newCol)
     ''' your code here '''
     if oldTile in self.posDict:
         if newTile in self.posDict[oldTile]:
             self.posDict[oldTile][newTile] += 1.0
         else:
             self.posDict[oldTile][newTile] = 1.0
     else:
         self.posDict[oldTile] = {newTile: 1.0}
Beispiel #3
0
    def noteCarMove(self, oldPos, newPos):
        oldRow, oldCol = util.yToRow(oldPos.y), util.xToCol(oldPos.x)
        newRow, newCol = util.yToRow(newPos.y), util.xToCol(newPos.x)
        oldTile = (oldRow, oldCol)
        newTile = (newRow, newCol)
        ''' your code here '''

        if not oldTile in self.info:
            self.info[oldTile] = {}
            self.info[oldTile][newTile] = 1
        else:
            if not newTile in self.info[oldTile]:
                self.info[oldTile][newTile] = 1
            else:
                self.info[oldTile][newTile] += 1
Beispiel #4
0
 def isCloseToOtherCar(self, beliefOfOtherCars):
     newBounds = []
     offset = self.dir.normalized() * 1.5 * Car.LENGTH
     newPos = self.pos + offset
     row = util.yToRow(newPos.y)
     col = util.xToCol(newPos.x)
     p = beliefOfOtherCars.getProb(row, col)
     return p > AutoDriver.MIN_PROB
 def isCloseToOtherCar(self, beliefOfOtherCars):
     newBounds = []
     offset = self.dir.normalized() * 1.5 * Car.LENGTH
     newPos = self.pos + offset
     row = util.yToRow(newPos.y)
     col = util.xToCol(newPos.x)
     p = beliefOfOtherCars.getProb(row, col)
     return p > AutoDriver.MIN_PROB
Beispiel #6
0
 def isCloseToOtherCar(self, beliefOfOtherCars):
     newBounds = []
     # The multiplier was 1.5
     offset = self.dir.normalized() * 1 * Car.LENGTH
     newPos = self.pos + offset
     row = util.yToRow(newPos.y)
     col = util.xToCol(newPos.x)
     p = beliefOfOtherCars.getProb(row, col)
     # print 'row:{0} col:{1} prob:{2}'.format(row,col,p);
     return p > AutoDriver.MIN_PROB
Beispiel #7
0
    def noteCarMove(self, oldPos, newPos):
        oldRow, oldCol = util.yToRow(oldPos.y), util.xToCol(oldPos.x)
        newRow, newCol = util.yToRow(newPos.y), util.xToCol(newPos.x)
        oldTile = (oldRow, oldCol)
        newTile = (newRow, newCol)

        if oldRow not in self.transTable:
            self.transTable[oldRow] = {}
            self.visitedTable[oldRow] = {}

        if oldCol not in self.transTable[oldRow]:
            self.transTable[oldRow][oldCol] = {}
            self.visitedTable[oldRow][oldCol] = 0

        self.visitedTable[oldRow][oldCol] += 1

        if newRow not in self.transTable[oldRow][oldCol]:
            self.transTable[oldRow][oldCol][newRow] = {}

        if newCol not in self.transTable[oldRow][oldCol][newRow]:
            self.transTable[oldRow][oldCol][newRow][newCol] = 0

        self.transTable[oldRow][oldCol][newRow][newCol] += 1
Beispiel #8
0
 def calculateErrorForCar(self, otherCar):
     pos = otherCar.getPos()
     carRow = util.yToRow(pos.y)
     carCol = util.xToCol(pos.x)
     belief = otherCar.getInference().getBelief()
     total = belief.getSum()
     if abs(total - 1.0) > 0.001:
         raise Exception('belief does not sum to 1. Use the normalize method.')
     totalError = 0
     for r in range(belief.getNumRows()):
         for c in range(belief.getNumCols()):
             prob = belief.getProb(r, c)
             difRow = r - carRow
             difCol = c - carCol
             error = math.sqrt(difRow ** 2 + difCol ** 2)
             errorSquared = error ** 2
             totalError += errorSquared * prob
     return totalError
Beispiel #9
0
 def getProbAtPos(self, beliefOfOtherCars, pos):
     row = util.yToRow(pos.y)
     col = util.xToCol(pos.x)
     p = beliefOfOtherCars.getProb(row, col)
     return p
Beispiel #10
0
 def noteCarMove(self, oldPos, newPos):
     oldRow, oldCol = util.yToRow(oldPos.y), util.xToCol(oldPos.x)
     newRow, newCol = util.yToRow(newPos.y), util.xToCol(newPos.x)
     oldTile = (oldRow, oldCol)
     newTile = (newRow, newCol)
     ''' your code here '''