def put_grand_summary_data(num_players):
    try:
        cnx = mysql.connector.connect(
            user=db_params["username"], password=db_params["password"], database=db_params["database"]
        )
        cur = cnx.cursor()

        insert_grand_summary = (
            "insert into gamesim_grand_summary_data "
            "(num_players, player_wins_total, player_hands_total, "
            "hand_type_wins_total, hand_type_hands_total, "
            "hole_hand_wins_total, hole_hand_hands_total, "
            "hole_hand_tied_wins_total) values (%(num_players)s, "
            "%(player_wins_total)s, %(player_hands_total)s, "
            "%(hand_type_wins_total)s, %(hand_type_hands_total)s, "
            "%(hole_hand_wins_total)s, %(hole_hand_hands_total)s, "
            "%(hole_hand_tied_wins_total)s); "
        )

        players, player_wins_total, player_hands_total = th_i.putPlayers(
            num_players,
            initialData["players_initial"],
            initialCounters["player_wins_initial"],
            initialCounters["player_hands_initial"],
        )

        player_wins_total = json.dumps(player_wins_total)
        player_hands_total = json.dumps(player_hands_total)
        hand_type_wins_total = json.dumps(initialCounters["hand_type_wins"])
        hand_type_hands_total = json.dumps(initialCounters["hand_type_hands"])
        hole_hand_wins_total = json.dumps(initialCounters["hole_hand_wins"])
        hole_hand_hands_total = json.dumps(initialCounters["hole_hand_hands"])
        hole_hand_tied_wins_total = json.dumps(initialCounters["hole_hand_tied_wins"])

        insert_data = {
            "num_players": str(num_players),
            "player_wins_total": player_wins_total,
            "player_hands_total": player_hands_total,
            "hand_type_wins_total": hand_type_wins_total,
            "hand_type_hands_total": hand_type_hands_total,
            "hole_hand_wins_total": hole_hand_wins_total,
            "hole_hand_hands_total": hole_hand_hands_total,
            "hole_hand_tied_wins_total": hole_hand_tied_wins_total,
        }

        cur.execute(insert_grand_summary, insert_data)
        cnx.commit()
        cnx.close
    except mysql.connector.Error as e:
        print(e.args[0])
        print(e.args[1])
        cnx.close
    return
Example #2
0
def put_grand_summary_data(num_players):
    try:
        cnx = mysql.connector.connect(user=db_params['username'], password = \
            db_params['password'], database= db_params['database'])
        cur = cnx.cursor()

        insert_grand_summary = (
            "insert into gamesim_grand_summary_data "
            "(num_players, player_wins_total, player_hands_total, "
            "hand_type_wins_total, hand_type_hands_total, "
            "hole_hand_wins_total, hole_hand_hands_total, "
            "hole_hand_tied_wins_total) values (%(num_players)s, "
            "%(player_wins_total)s, %(player_hands_total)s, "
            "%(hand_type_wins_total)s, %(hand_type_hands_total)s, "
            "%(hole_hand_wins_total)s, %(hole_hand_hands_total)s, "
            "%(hole_hand_tied_wins_total)s); ")

        players, player_wins_total, player_hands_total = th_i.putPlayers( \
            num_players, initialData['players_initial'], \
            initialCounters['player_wins_initial'], \
            initialCounters['player_hands_initial'])

        player_wins_total = json.dumps(player_wins_total)
        player_hands_total = json.dumps(player_hands_total)
        hand_type_wins_total = json.dumps(initialCounters['hand_type_wins'])
        hand_type_hands_total = json.dumps(initialCounters['hand_type_hands'])
        hole_hand_wins_total = json.dumps(initialCounters['hole_hand_wins'])
        hole_hand_hands_total = json.dumps(initialCounters['hole_hand_hands'])
        hole_hand_tied_wins_total = \
            json.dumps(initialCounters['hole_hand_tied_wins'])

        insert_data = {'num_players': str(num_players), 'player_wins_total': \
            player_wins_total, 'player_hands_total': player_hands_total, \
            'hand_type_wins_total':hand_type_wins_total, \
            'hand_type_hands_total': hand_type_hands_total, \
            'hole_hand_wins_total': hole_hand_wins_total, \
            'hole_hand_hands_total': hole_hand_hands_total, \
            'hole_hand_tied_wins_total': hole_hand_tied_wins_total}

        cur.execute(insert_grand_summary, insert_data)
        cnx.commit()
        cnx.close
    except mysql.connector.Error as e:
        print(e.args[0])
        print(e.args[1])
        cnx.close
    return
        cnx.commit() 
        cnx.close()
    except mysql.connector.Error as e:
        print(e.args[0])
        print(e.args[1])
        cnx.close()
    return
    
###############################################################################
##########    Start  GameSimulation   #########################################
###############################################################################
    
db_params = {'username':'******', 'password': '******', \
    'database': 'texasholdem_db'}

th_i.set_global_sql_variables()
    
delete_loop_status_data()
    
sim_id = int(sys.argv[1])

num_players, num_cpus, num_loops, num_games, sim_dir = \
    th_i.getSimulationParameters(sim_id)

os.chdir(sim_dir)

start1 = time.time()
run_time = get_run_time(sim_id)

python, childProcess = th_i.get_python_scripts()
players, player_wins_total, player_hands_total = th_i.get_initial_players()
Example #4
0
        cnx.close()       
    return

###############################################################################
########################  Game   ##############################################
#root_dir = 'C:\\Users\\Larry\\SkyDrive\\Python\\Django\\texasholdem1\\'
#app_dir = 'gamesim\\'
#sim_script_dir = 'sim_scripts\\'
#data_dir = 'data_dir\\'
        
cpuNum = '1'

db_params = {'username':'******', 'password': '******', \
    'database': 'texasholdem_db'}
    
th_i.set_global_sql_variables()

sim_id = int(sys.argv[1])
numberOfGames, save_game_data = th_i.getSimulationParametersChild(sim_id)

Players, Player_Wins, Player_Hands = th_i.get_game_players()

CardSuits, CardRanks, CardRankNumbers = th_i.get_cards()
HandTypes, HandType_Ranks = th_i.get_hands()
HandType_Wins, HandType_Hands = th_i.get_hand_counters()

DistinctHoleHands = th_i.get_hole_hands()
    
DistinctHoleHands2_Wins, DistinctHoleHands2_Hands, \
    DistinctHoleHands2_TiedWins = th_i.get_hole_hand_counters()
Example #5
0
        cnx.close()
    except mysql.connector.Error as e:
        print(e.args[0])
        print(e.args[1])
        cnx.close()
    return


###############################################################################
##########    Start  GameSimulation   #########################################
###############################################################################

db_params = {'username':'******', 'password': '******', \
    'database': 'texasholdem_db'}

th_i.set_global_sql_variables()

delete_loop_status_data()

sim_id = int(sys.argv[1])

num_players, num_cpus, num_loops, num_games, sim_dir = \
    th_i.getSimulationParameters(sim_id)

os.chdir(sim_dir)

start1 = time.time()
run_time = get_run_time(sim_id)

python, childProcess = th_i.get_python_scripts()
players, player_wins_total, player_hands_total = th_i.get_initial_players()