Esempio n. 1
0
def gatherStatisticalData(statistics, currentPlayer):
    #Add the latest rewar to the statistics class
    I = currentPlayer.i
    J = currentPlayer.j
    statLength = len(statistics)
    currentReward = currentPlayer.rewards[I][J]

    if statLength != 0:
        statistics.append(
            currentReward
        )  #We append the current reward to the array which holds all of the statistical data

        previousRewardValue = statistics[
            (statLength) -
            1]  #Now using the iteration counter for the entire game we grab the previous reward
        deltaDiff = computeDeltadiff(previousRewardValue, currentReward)

        if deltaDiff != 0:

            print("Percentage Difference: ", deltaDiff, "%")
            print("The current reward is", currentReward)
            print("------------------")
            return deltaDiff  #We compute the percent different between the two rewards in hopes of getting a threshold value that is less than some value for convergence
        elif deltaDiff == 0:
            #Then we may want to run through a few iterations to see how it plays out
            print("Percentage Difference: ", deltaDiff, "%")
            print("The current reward is", currentReward)
            print("------------------")
            return deltaDiff
    elif statLength == 0:  #Then our statlenghth is = 0
        statistics.append(currentReward)  #Append the current reward at least

        return 100  #Return an abrturary value such as 100 %
screen = pygame.display.set_mode(SIZE, pygame.RESIZABLE)
pygame.display.set_caption("Rental Request Sort")


for i in range(num_res):
    TYPE_OF_CAR = r.choice(car_type)
    RANDOM_START_TIME = r.randint(1,(y))
    NUMBER_OF_HOURS = r.randint(1,(z))
    garage_type = r.choice(garage)
    st.append(RANDOM_START_TIME)
    nh.append(NUMBER_OF_HOURS)
    index.append(i)
    ct.append(TYPE_OF_CAR)
    g.append(garage_type)
    s.append('0')
    
for i in range(num_res):
    TYPE_OF_CAR1 = r.choice(car_type)
    RANDOM_START_TIME1 = r.randint(1,(y))
    NUMBER_OF_HOURS1 = r.randint(1,(z))
    garage_type1 = r.choice(garage1)
    st1.append(RANDOM_START_TIME1)
    nh1.append(NUMBER_OF_HOURS1)
    index1.append(i)
    ct1.append(TYPE_OF_CAR1)
    g1.append(garage_type1)
    s1.append('0')
# print(s)
    
# print(st, nh, index, ct, g)
Esempio n. 3
0
screen = pygame.display.set_mode(SIZE, pygame.RESIZABLE)
pygame.display.set_caption("Rental Request Sort")


for i in range(num_res):
    TYPE_OF_CAR = r.choice(car_type)
    RANDOM_START_TIME = r.randint(1,(y))
    NUMBER_OF_HOURS = r.randint(1,(z))
    garage_type = r.choice(garage)
    st.append(RANDOM_START_TIME)
    nh.append(NUMBER_OF_HOURS)
    index.append(i)
    ct.append(TYPE_OF_CAR)
    g.append(garage_type)
    s.append('-1')
    
for i in range(num_res):
    TYPE_OF_CAR1 = r.choice(car_type)
    RANDOM_START_TIME1 = r.randint(1,(y))
    NUMBER_OF_HOURS1 = r.randint(1,(z))
    garage_type1 = r.choice(garage1)
    st1.append(RANDOM_START_TIME1)
    nh1.append(NUMBER_OF_HOURS1)
    index1.append(i)
    ct1.append(TYPE_OF_CAR1)
    g1.append(garage_type1)
    s1.append('-1')
# print(s)
    
# print(st, nh, index, ct, g)
        d = {
            **d,
            **len_stats,
            **db55l_stats,
            **db60l_stats,
            **db65l_stats,
            **db70l_stats,
            **db55r_stats,
            **db60r_stats,
            **db65r_stats,
            **db70r_stats,
            **nei_stats,
            **nei_norm_stats,
            **mdB_stats
        }
        stats.append(d)
    else:
        errors.append(key)
print('stats got for:', len(stats), 'axyinds')
print('all paths filtered out for:', len(errors), 'axyinds')

#%% combine stats to DF
stats_df = pd.DataFrame(stats, columns=stats[0].keys())
stats_df.head()

#%% merge grid geoometry to axyind stats
grid_stats = pd.merge(stats_df,
                      grid,
                      how='left',
                      left_on='axyind',
                      right_on='xyind')