Beispiel #1
0
Log.printString('\nEpoch Win totals for this generation: ' + str(epoch_win) +
                '\n',
                log_path,
                access="a")
exportGenPerformance(gen_number, epoch_win)
print(epoch_win, '\n')

if gen_number >= 0:
    df_training.to_csv(output_dir + 'Generation_' + str(gen_number) + '.csv',
                       index=False,
                       quotechar='"',
                       quoting=csv.QUOTE_NONNUMERIC)
else:
    df_training.to_csv(output_dir + 'StartGeneration.csv',
                       index=False,
                       quotechar='"',
                       quoting=csv.QUOTE_NONNUMERIC)

if gen_number >= 0:
    shutil.copyfile(
        'C:/Users/akami/Documents/GitHub/Projects/BlackJackNeuralNetwork/TrainingData/GenerationFiles/ModelFiles/epoch_'
        + str(indexOfGreatest(epoch_win)) + '.h5',
        'C:/Users/akami/Documents/GitHub/Projects/BlackJackNeuralNetwork/TrainingData/Corpus/ModelFiles/Generation_'
        + str(gen_number) + '.h5')

log_str = 'The Script has finished at ' + str(time.asctime(
    time.localtime())) + '\nRuntime: ' + Log.secToHour(
        time.time() - start_time, inLine=False)
log_str += 'Length of Output: ' + str(len(df_training)) + '\n'
Log.printString(log_str, log_path, access="a", buffer=True)
Beispiel #2
0
        if last_scenario.WinLoss == 1:
            log.printString('\tThis Scenario has won\n', log_path, access='a')
        else:
            log.printString('\tThis Scenario has lost\n', log_path, access='a')

        scenarios = scenarios + output
    log_str = 'Scenario ' + str(i) + ' has completed\n'
    if wl_stats[0] + wl_stats[1] > 0:
        log_str += '\t- The model has a win percentage of ' + str(
            100 * wl_stats[0] / (wl_stats[0] + wl_stats[1])) + ' %\n'
    log_str += '\t- Wins: ' + str(wl_stats[0]) + '\tLoses: ' + str(
        wl_stats[1]) + '\tTies: ' + str(wl_stats[2])
    log.printString('\t- ' + log_str + '\n', log_path, access='a')

df_out.to_csv(out_path, index=False)

script_end = time.time()
log_str = '\nScript has completed at ' + str(time.asctime(
    time.localtime())) + '\nThe script took ' + str(
        log.secToHour(script_end - script_start, inLine=True)) + '\n'
if wl_stats[0] + wl_stats[1] > 0:
    log_str += 'The model has a win percentage of ' + str(
        100 * wl_stats[0] / (wl_stats[0] + wl_stats[1])) + ' %\n'
else:
    log_str += 'The model has a win percentage of 0%\n'
log_str += 'Wins: ' + str(wl_stats[0]) + '\tLoses: ' + str(
    wl_stats[1]) + '\tTies: ' + str(wl_stats[2]) + '\n'
log.printString(log_str, log_path, access='a', buffer=True)
#print('Wins: ' + str(wl_stats[0]) + '\tLoses: ' + str(wl_stats[1]) + '\tTies: ' + str(wl_stats[2]) +'\n')
Beispiel #3
0
  try:
    os.remove(out_path)
  except Exception as ex:
    pass

  df = pd.DataFrame()

  cardDeck = CardDeck(num_deck)
  TotalCount = 0

  for i in range(num_training):
    log.printString('\nTraining Number ' + str(i) + ':\n', log_path, access='a')
    
    if (cardDeck.NumDeck * 52) - cardDeck.currentCard <= 20:
      cardDeck.shuffleCards()
      TotalCount = 0

    df_out = playIteration( cardDeck, TotalCount )
    TotalCount = df_out.iloc[0].TotalCount
    df = df.append(df_out, ignore_index= True)
    
    log.printString( log.logDf(df), log_path, access='a' )
  df.to_csv(out_path, index= False)

  end_time = time.time()
  log_str = 'The Script has finished running at ' + str(time.asctime(time.localtime())) + '\nThe runtime was ' + log.secToHour( end_time - start_time, inLine= True) + '\n'
  log_str += 'Win Percentage: ' + str(100 * wl_stats[0] / (wl_stats[0] + wl_stats[1])) + ' %\n'
  log_str += 'Wins: ' + str(wl_stats[0]) + '\tLosses: ' + str(wl_stats[1]) + '\tTies: ' + str(wl_stats[2]) + '\n' 
  log.printString( log_str, log_path, access='a', buffer=True)
  #print('Wins: ' + str(wl_stats[0]) + '\tLosses: ' + str(wl_stats[1]) + '\tTies: ' + str(wl_stats[2]) + '\n')