Beispiel #1
0
training_data = list()
RANDOM_FACTOR=0

temp = 0
oldREWSUM = 0

while (1):
        clock.tick(60)
        for event in pygame.event.get():
            #print(event)
                    
            if event.type == pygame.QUIT:#for exiting the game
                    Game.QUITGAME()
            if event.type == pygame.KEYDOWN:
                    if event.key ==pygame.K_DOWN:
                            MyFunctions.GRAPH_REWARDS(rewards_array_L, rewards_array_R, rounds_array)

        
        if np.random.binomial(1,EPSILON):
                #print (np.shape(STATE))
                AVR = session.run(Q_R, feed_dict = {State_InR: [STATE]})
                AVR = MyFunctions.ONE_HOT_ACTIONS(AVR)
        else:
                AVR = MyFunctions.RANDOM_ONE_HOT()

        
        if np.random.binomial(1,EPSILON):
                #print (np.shape(STATE))
                AVL = session.run(Q_L, feed_dict = {State_InL: [STATE]})
                AVL = MyFunctions.ONE_HOT_ACTIONS(AVL)
        else:
    RRewSUM = RRewSUM + R
    #print([L,R,AVL,AVR, DATA])
    training_data.append(
        [np.copy(OLD_STATE), L, R, AVL[:], AVR[:],
         np.copy(STATE)])

    if (L != 0):
        NUM_ROUNDS_PLAYED = NUM_ROUNDS_PLAYED + 1

    time_step = time_step + 1

    for event in pygame.event.get():
        #print(event)
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_DOWN:
                MyFunctions.GRAPH_REWARDS(rewards_array)

        if event.type == pygame.QUIT:  #for exiting the game
            results_file.close()
            Game.QUITGAME()

    if time_step % 5000 == 0:
        line = str(time_step) + ',' + str(LRewSUM) + ';'
        rewards_array.append(LRewSUM)
        print(line)
        results_file.write(line)
        temp = NUM_ROUNDS_PLAYED
        LRewSUM = 0
        RRewSUM = 0

    if time_step % 100000 == 0: