I have made a class in which there are 3 functions.
- def maxvalue
- def min value
- def getAction
In the def maxvalue function, I have made a list of actions. I want that list to be accessed in def getaction function so that I can reverse the list and then take out the first entry from it. How can do i that??
def getAction(self,gamestate):
bestaction.reverse()
return bestaction[0]
def maxvalue(gameState, depth):
actions = gameState.getLegalActions(0);
v = -9999
bestaction = []
for action in actions:
marks = minvalue(gameState.generateSuccessor(0, action), depth, 1)
if(v < marks):
v = marks
bestaction.append(action)
return v
It is giving me an error....."global name bestaction is not defined"