def load_objects_values(): '''Initializes objects values, a list with an entry for each object, initialized at 0.''' objects_values = {} objects = model.get_objects() for object in objects: objects_values[object.id] = 0 return objects_values
def GET(self): '''Renders a page listing all of the objects so that they can be retrained.''' objects = model.get_objects() return render.data(list(objects))
def GET(self): '''Lists all of the objects so that selected objects can be deleted.''' objects = model.get_objects() return render.delete_object(objects)
new_object_id = model.add_object(name) ### adds to database and trains learn(asked_questions, new_object_id) return new_object_id def learn(asked_questions, object_id): '''Updates the data for the correct object based on information in asked_questions. Also updates times played for the object and stores the playlog.''' for question in asked_questions: current_weight = model.get_value(object_id, question) if not(current_weight): current_weight = 0 new_weight = current_weight + asked_questions[question] model.update_data(object_id, question, new_weight) model.update_times_played(object_id) model.record_playlog(object_id, asked_questions, True) if __name__ == '__main__': ##### Tests entropy! ##### objects = model.get_objects() objects = [object.id for object in objects] objects = tuple(objects) questions = model.get_questions() for question in questions: print question.id print 'DAN:', simple_entropy(objects, question) print 'ANDY:', entropy(objects, question)