Пример #1
0
def edit_word():                    #새로운 단어를 추가
    print("ADD:1    REMOVE:2")
    user_choice=int(input("Choice: "))
    print("Write only word")
    new_word=input("word: ")

    if user_choice==1:
        if compare_word(new_word) == False:    #존재하는 단어를 입력한 경우 다음 문장을 프린트
            print("It already exists")
            return
        else:                                  #존재하지 않는 단어를 입력한 경우 다음 문장을 프린트
            datafile=open("./Info/game_word.txt", "a")
            datafile.write(new_word + '\n')
            datafile.close()
            text="%s is added" %new_word
            print(text)

    elif user_choice==2:                      #단어 삭제 함수

        if not compare_word(new_word):  #사실상 필요없는 참거짓과 삭제할 단어의 위치 반환
            remove_word_poitsion=getPosition(new_word)
            if remove_word_poitsion==False:
                print("No word")

            else:
                word_list=load_word_data()
                print("Remove " + word_list[remove_word_poitsion])
                del(word_list[remove_word_poitsion])   #단어 삭제
                write_file(word_list)
Пример #2
0
    def initializeDataSet(self):
        if len(self.input_value) != len(self.output_value):
            print "Input and output arrays aren't the same size."
            exit()

        for i in range(0, len(self.input_value)):
            self.ds.addSample(
                self.input_value[i], utils.getPosition(self.output_value[i], results))
Пример #3
0
	def scoreProbaByPLayer(self,resproba,target):
		dtotal={}
		d0={}
		for i in range(len(target)):
			p=target[i].player1
			a=utils.getPosition(p,resproba[i])
			dtotal[p]=dtotal.get(p,0)+1
			if a==0:
				d0[p]=d0.get(p,0)+1
				
		for p in dtotal:
			print("{0} is at {3}% of success ({1} good,{4} bad, total: {2})".format(p,d0.get(p,0),dtotal[p],round(100*float(d0.get(p,0))/dtotal[p],2), dtotal[p]-d0.get(p,0)))
Пример #4
0
    def scoreProbaByPLayer(self, resproba, target):
        dtotal = {}
        d0 = {}
        for i in range(len(target)):
            p = target[i].player1
            a = utils.getPosition(p, resproba[i])
            dtotal[p] = dtotal.get(p, 0) + 1
            if a == 0:
                d0[p] = d0.get(p, 0) + 1

        for p in dtotal:
            print("{0} is at {3}% of success ({1} good,{4} bad, total: {2})".
                  format(p, d0.get(p, 0), dtotal[p],
                         round(100 * float(d0.get(p, 0)) / dtotal[p], 2),
                         dtotal[p] - d0.get(p, 0)))
Пример #5
0
    def trainingOnDataSet(self):
        trainer = BackpropTrainer(self.n, self.ds)
        result = 200
        while result > 100:
            result = trainer.train()
            print result


        newds = SupervisedDataSet(
            self.pix_size * self.pix_size, len(results))

        newds.addSample(
                self.input_value[0], utils.getPosition('a', results))

        print 'MSE train', trainer.testOnData(newds, verbose = True)
Пример #6
0
    def scoreProba(self, resproba, target, threshold=200, dbtest=None):
        #resproba is a list of sorted ordered dict with name as key and (value,game) as value
        fail = 0
        bad_failure = 0
        bad_replay = 0
        s = 0
        st = 0
        sumt = 0
        probafalsenegative = 0
        for i in range(len(resproba)):

            a = utils.getPosition(target[i].player1, resproba[i])
            if dbtest != None:
                prob = []
                for k in range(4):
                    plog = dbtest.getProbaPlayer(resproba[i][k][1],
                                                 resproba[i][k][0])
                    if plog != 0:
                        prob.append(math.log10(plog))
                    else:
                        prob.append(-10000)
                #proba0=dbtest.getProbaPlayer(resproba[i][0][1],resproba[i][0][0])
                #proba1=dbtest.getProbaPlayer(resproba[i][1][1],resproba[i][1][0])
                #proba2=dbtest.getProbaPlayer(resproba[i][2][1],resproba[i][2][0])

                str1 = ""

                if (a != -1):
                    plog = dbtest.getProbaPlayer(resproba[i][a][1],
                                                 resproba[i][a][0])
                    if plog != 0:
                        prob.append(math.log10(plog))
                    else:
                        prob.append(-10000)
                else:
                    prob.append(100)

            if (a == threshold or (threshold == 200 and a > 0)):
                if (prob[0] < prob[1] or prob[0] < prob[2]):
                    probafalsenegative += 1
                    str1 = ("WARNING!!")
                stra = ""

                for k in range(len(prob)):
                    if (k == len(prob) - 1):
                        b = a
                    else:
                        b = k
                    tab = "\t"
                    if (len(resproba[i][b][0]) < 10):
                        tab = "\t\t"
                    stra += ("{3}:{0}: {1} p:{2}|" + tab).format(
                        resproba[i][b][0], round(resproba[i][b][1], 2),
                        round(prob[k], 2), b)

                print(("{0}:{1} |" + stra + str1).format(i, target[i].player1))
                st += 1
                sumt += resproba[i][0][1]
                if (a > 0):
                    fail += 1
                if (a > 2):
                    bad_failure += 1
                if (resproba[i][0][1] > 1):
                    bad_replay += 1
        if (st != 0):
            print(
                "number of position {0}: {1} with mean value {2}| number of warning {3}"
                .format(threshold, st, round(sumt / st, 2),
                        probafalsenegative))
        if (threshold == 200):
            print(
                "Number of games: {0},number of failure {1}({2})% , number of bad failure(>2) {3}({5}%) ,failure not bad {8}, bad replay {4}({6}%) bad failure less bad replay {7}({9}%)|{10} "
                .format(
                    len(target),
                    fail,
                    round(float(fail) / len(target) * 100, 3),
                    bad_failure,
                    bad_replay,
                    round(float(bad_failure) / len(target) * 100, 2),
                    round(float(bad_replay) / len(target) * 100, 2),
                    bad_failure - bad_replay  #7
                    ,
                    fail - bad_failure,
                    round(float(s - bad_failure) / len(target), 2),
                    probafalsenegative))

            #################
        """
Пример #7
0
	def scoreProba(self,resproba,target,threshold=200,dbtest=None):
		#resproba is a list of sorted ordered dict with name as key and (value,game) as value
		fail=0
		bad_failure=0
		bad_replay=0
		s=0
		st=0
		sumt=0
		probafalsenegative=0
		for i in range(len(resproba)):
			
			a=utils.getPosition(target[i].player1,resproba[i])
			if dbtest!=None:
				prob=[]
				for k in range(4):
					plog=dbtest.getProbaPlayer(resproba[i][k][1],resproba[i][k][0])
					if plog!=0:		
						prob.append(math.log10(plog))
					else:
						prob.append(-10000)
				#proba0=dbtest.getProbaPlayer(resproba[i][0][1],resproba[i][0][0])
				#proba1=dbtest.getProbaPlayer(resproba[i][1][1],resproba[i][1][0])
				#proba2=dbtest.getProbaPlayer(resproba[i][2][1],resproba[i][2][0])
				
				str1=""
				
				if(a!=-1):
					plog=dbtest.getProbaPlayer(resproba[i][a][1],resproba[i][a][0])
					if plog!=0:		
						prob.append(math.log10(plog))
					else:
						prob.append(-10000)
				else:
					prob.append(100)
			
			if (a==threshold or (threshold==200 and a>0)):
				if(prob[0]< prob[1] or prob[0]<prob[2]):
						probafalsenegative+=1
						str1=("WARNING!!")
				stra=""

				for k in range(len(prob)):
					if(k==len(prob)-1):
						b=a
					else:
						b=k
					tab="\t"
					if(len(	resproba[i][b][0])<10):
						tab="\t\t"
					stra+=("{3}:{0}: {1} p:{2}|"+tab).format(resproba[i][b][0],round(resproba[i][b][1],2),round(prob[k],2),b)
				  
				print(("{0}:{1} |"+stra+str1).
				format(i,target[i].player1))
				st+=1
				sumt+=resproba[i][0][1]
				if(a>0):
					fail+=1
				if(a>2):
					bad_failure+=1
				if(resproba[i][0][1]>1):
					bad_replay+=1
		if (st!=0):			
			print("number of position {0}: {1} with mean value {2}| number of warning {3}".format(threshold,st,round(sumt/st,2),probafalsenegative))
		if(threshold==200):
			print("Number of games: {0},number of failure {1}({2})% , number of bad failure(>2) {3}({5}%) ,failure not bad {8}, bad replay {4}({6}%) bad failure less bad replay {7}({9}%)|{10} ".format(
			len(target),						
			fail,									
			round(float(fail)/len(target)*100,3),	
			bad_failure,
			bad_replay,
			round(float(bad_failure)/len(target)*100,2)
			,round(float(bad_replay)/len(target)*100,2)
			,bad_failure-bad_replay		#7
			,fail-bad_failure,
			round(float(s-bad_failure)/len(target),2),
			probafalsenegative))
			
			
			#################			
		"""
Пример #8
0
	def script_position(self, gesture=None):
		return ui.message('{0}% ({1}/{2})'.format(round(utils.getPositionPercentage(), 2), utils.getPosition()[0], utils.getPosition()[1]))