def trainingGame(self): N=smartRawInput("how many numbers",12,int) fstep=smartRawInput("which freq step",0.04,float) threshold=smartRawInput("max deviation (s) before increasing/decreasing numbers",0.15,float) Ninc=smartRawInput("how many numbers are added when threshold is reached",6,int) freq=1 while True: self.displayLearningMaterial(N,freq) ans=raw_input("your answer : ") if(self.solution!=ans): freq+=fstep print("wrong") print("the solution: %s"%(self.solution)) if(abs(freq-1)>threshold)and(N-Ninc>0): if(N-Ninc>0): N=N-Ninc freq=1 print("Threshold reached : settings are now %.2f for %d items"%(freq,N)) else: print("success") freq-=fstep if(abs(freq-1)>threshold): N=N+Ninc freq=1 print("Threshold reached : settings are now %.2f for %d items"%(freq,N)) print("current freq : %.2f "%(freq)) d=raw_input("enter to continue, q to quit : ") if(d=="q"): print("you stopped at %.2f for %d items"%(freq,N)) return
def trainingRT(self): # I am a cpy paste moron here dics=profileLoaderForReactionTraining('user/profile.properties','c') loadSet="n" if(len(dics)!=0): loadSet = smartRawInput('we have found special settings for this feat, load (y/n)',"y") if(loadSet=="y"): listOfSystem=[system["system"] for system in dics] # get the systems as a list pick=multipleChoice(listOfSystem) # user has multiple choice selectedSystem=dics[pick] # ... no pun intended f1=open(csvReactionTime2, 'a') nbCards=-1 #value by default to avoid bug if(loadSet!="y"): raw_input('no system for this feat has been selected, but you can work on single items push enter') nbCards = smartRawInput('how many cards ? ',"2",int) # COULD BE IMPROVED TO CREATE A SYSTEM letter = smartRawInput('write a single letter to represent this system (keep the same letter later) ',"Y") selectedSystem={'imagesSize': {letter: str(nbCards)}, 'system': letter} pref=smartRawInput("full cards (f) of corner (r) ?","f") if(pref=="r"): self.cardPrefix="corner" coef=smartRawInput("attenuation coefficient in %",25,float) meta_coef=smartRawInput("meta attenuation coefficient in %",5,float) meta_coef=1+float(meta_coef)/100 c=1+float(coef)/100 t=smartRawInput("how much practice in seconds",180,float) inhib=smartRawInput("minimal gap between items",3,int) record = smartRawInput('record data (y/n)',"y") lastIt=lastItems(inhib) try: controlStructure = pickle.load( open( pickleRt, "rb" ) ) except : # if no data stored start with a home made dictionnary controlStructure=None if((controlStructure==None)or(selectedSystem['system'] not in controlStructure["system"])): # the way to get system wont work with digits only # if a system is already in we do not update, can cause problem if the system of the user is updated controlStructure=buildAStructure(controlStructure,selectedSystem,mode="c") controlStructure["infos"]["compteur"]=controlStructure["infos"]["compteur"]+1 trials=0 self.pgInit() self.write_instruction("enter to pass, escape to quit", self.font_stimuli) self.wait_enter() startExp=time.clock() ######## TRAINING LOOP ######## start = time.clock() last_time = start cont=True pg.display.flip() items,lastIt = displayItemForTrainingRT(lastIt, controlStructure,selectedSystem,nbCards) itemsToDisplay=self.textTopictureNotationForCollection(items) self.display_pictures(itemsToDisplay) while cont: for event in pg.event.get(): if event.type==pg.KEYDOWN: curent=time.clock() trials+=1 if event.key == pg.K_ESCAPE or((curent-startExp)>t): pickle.dump( controlStructure, open( pickleRt, "wb" ) ) self.write_instruction("during your training during %d s, you have seen %d items"%(t,trials)) self.wait_enter() cont = False break timeElapsed=curent-last_time timeElapsed_tosend=timeElapsed if(timeElapsed>6)or(timeElapsed<0.3): timeElapsed_tosend=-1 if(record=="y")and(timeElapsed_tosend!=-1): controlStructure=updateControlStructure(controlStructure,selectedSystem,nbCards,items,timeElapsed_tosend,c,meta_coef) f1.write(str(controlStructure["infos"]["compteur"])+";"+selectedSystem['system']+";"+str(trials)+";"+str(time.time())+";"+str(timeElapsed)+";"+"".join(items)+ ";geometricOdd;"+str(inhib)+";"+str(c)+";"+str(meta_coef)+";"+str(t)+"\n") last_time=time.clock() items,lastIt = displayItemForTrainingRT(lastIt, controlStructure,selectedSystem,nbCards) itemsToDisplay=self.textTopictureNotationForCollection(items) self.display_pictures(itemsToDisplay) pg.quit() printSumStruc(controlStructure,selectedSystem)
def trainingGame(self,mode="amort"): # TODO: some functions must be taken from a parent class reserved for reaction time training if(mode=="amort"): dics=profileLoaderForReactionTraining('user/profile.properties','d') loadSet="n" if(len(dics)!=0): loadSet = smartRawInput('we have found special settings for this feat, load (y/n)',"y") if(loadSet=="y"): listOfSystem=[system["system"] for system in dics] # get the systems as a list pick=multipleChoice(listOfSystem) # user has multiple choice selectedSystem=dics[pick] # ... no pun intended f1=open(csvReactionTime2, 'a') nbDigits=-1 #value by default to avoid bug if(loadSet!="y"): raw_input('no system for this feat has been selected, but you can work on single items push enter') nbDigits = smartRawInput('how many digits ? ',"2",int) # COULD BE IMPROVED TO CREATE A SYSTEM letter = smartRawInput('write a single letter to represent this system (keep the same letter later) ',"Z") selectedSystem={'imagesSize': {letter: str(nbDigits)}, 'system': letter} coef=smartRawInput("attenuation coefficient in %",25,float) meta_coef=smartRawInput("meta attenuation coefficient in %",5,float) meta_coef=1+float(meta_coef)/100 c=1+float(coef)/100 t=smartRawInput("how much practice in seconds",180,float) inhib=smartRawInput("minimal gap between items",3,int) sepSign=smartRawInput("separator between numbers(n for none)","|") if(sepSign=="n"): sepSign="" record = smartRawInput('record data (y/n)',"y") lastIt=lastItems(inhib) try: controlStructure = pickle.load( open( pickleRt, "rb" ) ) except : # if no data stored start with a home made dictionnary controlStructure=None if((controlStructure==None)or(selectedSystem['system'] not in controlStructure["system"])): # the way to get system wont work with digits only # if a system is already in we do not update, can cause problem if the system of the user is updated controlStructure=buildAStructure(controlStructure,selectedSystem,mode="d") controlStructure["infos"]["compteur"]=controlStructure["infos"]["compteur"]+1 trials=0 waiter() startExp=time.clock() ######## TRAINING LOOP ######## while(True): startTrial= time.clock() trials+=1 items,lastIt = displayItemForTrainingRT(lastIt, controlStructure,selectedSystem,nbDigits,sepSign) Userinput=raw_input("") nt=time.clock() if (Userinput=="q")or((nt-startExp)>t): pickle.dump( controlStructure, open( pickleRt, "wb" ) ) print("during your training during %d s, you have seen %d items"%(t,trials)) printSumStruc(controlStructure,selectedSystem) break timeElapsed=nt-startTrial timeElapsed_tosend=timeElapsed if(timeElapsed>6)or(timeElapsed<0.3): timeElapsed_tosend=-1 if(record=="y")and(timeElapsed_tosend!=-1): controlStructure=updateControlStructure(controlStructure,selectedSystem,nbDigits,items,timeElapsed_tosend,c,meta_coef) f1.write(str(controlStructure["infos"]["compteur"])+";"+selectedSystem['system']+";"+str(trials)+";"+str(time.time())+";"+str(timeElapsed)+";"+"".join(items)+ ";geometricOdd;"+str(inhib)+";"+str(c)+";"+str(meta_coef)+";"+str(t)+"\n")
#!/usr/bin/env python # -*- coding: utf-8 -*- from mnemy.disciplines import Binaries, Words, Numbers, SpokenNumbers, Dates, profileLoader, errorsLoader, reportDatas,loadAndCheckJourney, Cards, AbstractImages,NameAndFaces from mnemy.utils import smartRawInput import time # TODO : avoid permission denied error by looping if __name__ == "__main__": while True: training=smartRawInput("Special training(s) or test yourself(t)","s") if(training=="s"): train=raw_input("pick your discipline (d=digits,c=Cards,k=spokenNumber) : ") if(train=="k"): ff=SpokenNumbers() elif(train=="d"): ff=Numbers() elif(train=="c"): ff=Cards() else: raise Exception("sorry no training game for this feat") ff.trainingGame() else: #=========================================================================== # Load Discipline Parameters #=========================================================================== feat=raw_input("pick your discipline (d=digits,b=binaries,w=words,h=historicalDates,s=SpeedCards,c=Cards,a=AbstractImages,n=NameAndFaces) : ")