def random_player(self,state): #find the actions for the state stateId = SamplingUtility.getStateId(state) #print 'state '+ str(state)[1:-1] #if len(self.Q_value_function) == 0 or not self.Q_value_function.has_key(stateId): #len() : Return the length (the number of items) of an object. self.all_allowed_actions[stateId] = InvasiveUtility.getActions(state, self.nbrReaches, self.habitatSize) #self.Q_value_function[stateId] = len(self.all_allowed_actions[stateId]) * [0.0] index = self.randGenerator.randint(0, len(self.all_allowed_actions[stateId]) - 1) return self.all_allowed_actions[stateId][index]
def egreedy(self, state): #find the actions for the state stateId = SamplingUtility.getStateId(state) #print 'state '+ str(state)[1:-1] if len(self.Q_value_function) == 0 or not self.Q_value_function.has_key(stateId): self.all_allowed_actions[stateId] = InvasiveUtility.getActions(state, self.nbrReaches, self.habitatSize) self.Q_value_function[stateId] = len(self.all_allowed_actions[stateId]) * [0.0] if not self.exploringFrozen and self.randGenerator.random() < self.sarsa_epsilon: index = self.randGenerator.randint(0, len(self.all_allowed_actions[stateId]) - 1) else: index = self.Q_value_function[stateId].index(max(self.Q_value_function[stateId])) #print 'a '+str(self.all_allowed_actions[stateId][index])[1:-1] return self.all_allowed_actions[stateId][index]
def random_player(self, state): #find the actions for the state stateId = SamplingUtility.getStateId(state) #print 'state '+ str(state)[1:-1] #if len(self.Q_value_function) == 0 or not self.Q_value_function.has_key(stateId): #len() : Return the length (the number of items) of an object. self.all_allowed_actions[stateId] = InvasiveUtility.getActions( state, self.nbrReaches, self.habitatSize) #self.Q_value_function[stateId] = len(self.all_allowed_actions[stateId]) * [0.0] index = self.randGenerator.randint( 0, len(self.all_allowed_actions[stateId]) - 1) return self.all_allowed_actions[stateId][index]