rein q6
This commit is contained in:
@ -192,12 +192,21 @@ class ApproximateQAgent(PacmanQAgent):
|
||||
where * is the dotProduct operator
|
||||
"""
|
||||
"*** YOUR CODE HERE ***"
|
||||
featureVector = self.featExtractor.getFeatures(state, action)
|
||||
qValue = 0
|
||||
for feature in featureVector:
|
||||
qValue += self.weights[feature] * featureVector[feature]
|
||||
return qValue
|
||||
|
||||
def update(self, state, action, nextState, reward: float):
|
||||
"""
|
||||
Should update your weights based on transition
|
||||
"""
|
||||
"*** YOUR CODE HERE ***"
|
||||
featureVector = self.featExtractor.getFeatures(state, action)
|
||||
difference = reward + self.discount * self.computeValueFromQValues(nextState) - self.getQValue(state, action)
|
||||
for feature in featureVector:
|
||||
self.weights[feature] += self.alpha * difference * featureVector[feature]
|
||||
|
||||
|
||||
def final(self, state):
|
||||
|
Reference in New Issue
Block a user