Example #1
0
def main_menu():
    set_name()
    check_if_name_in_data_and_replace()

    print(
        f"Hello {new_player.name}\nYour starting balance is {new_player.balance}.\nGood Luck!\n"
    )
    game_picked_by_player = game_pick()
    playing_deck = Deck()

    while game_picked_by_player != 9:
        while game_picked_by_player in [1, 2, 3, 4, 7, 8]:
            if game_picked_by_player == 1:
                run_war()
                game_picked_by_player = game_pick()

            if game_picked_by_player == 2:
                roulette()
                game_picked_by_player = game_pick()

            if game_picked_by_player == 3:
                play_bj()
                game_picked_by_player = game_pick()

            if game_picked_by_player == 4:
                run_tictactoe_game()
                game_picked_by_player = game_pick()

            if game_picked_by_player == 7:
                show_high_score()
                game_picked_by_player = game_pick()

            if game_picked_by_player == 8:
                saving_loading_menu()
                game_picked_by_player = game_pick()

        else:

            if game_picked_by_player != 9:
                game_picked_by_player = wrong_input()
            else:
                if input(
                        "Would you like to save your progress? y or n") == 'y':
                    save_progress()
                break
    if game_picked_by_player == 9:
        print(
            f"Your end balance: {new_player.get_balance()}\nGoodbye {new_player.name}"
        )
Example #2
0
 def __init__(self, x, y, btime, parent=None):
     self.btime = btime
     if parent == None:
         self.size = np.random.uniform(low=5.0, high=50)
         self.size_norm = self.size / 50.0
         self.size_cap = 50
         self.speed = np.random.uniform(low=0.0, high=10.0)
         self.speed_norm = self.speed / 10.0
         self.attack = np.random.uniform(low=0.0, high=1.0)
         self.stamina_cap = np.random.uniform(low=0.0, high=1.0)
         self.aggressiveness = np.random.uniform(low=0.0, high=1.0)
         self.metabolism = np.random.uniform(low=0.0, high=1.0)
         self.sight = np.random.uniform(low=0.0, high=200.0)
         self.sight_norm = self.sight / 200.0
         self.grate = np.random.uniform(low=0.0, high=1.0)
         self.hunger = np.random.uniform(low=0.0, high=1.0)
         self.brate = np.random.uniform(low=0.0, high=1.0)
         self.drate = np.random.uniform(low=0.0, high=1.0)
     else:
         self.size = parent.size + np.random.normal(0.0, 0.1)
         self.size_norm = self.size / 50.0
         self.size_cap = 50
         self.speed = parent.speed + np.random.normal(0.0, 0.1)
         self.speed_norm = self.speed / 10.0
         self.attack = parent.attack + np.random.normal(0.0, 0.1)
         self.stamina_cap = parent.stamina_cap + np.random.normal(0.0, 0.1)
         self.aggressiveness = parent.aggressiveness + np.random.normal(
             0.0, 0.1)
         self.metabolism = parent.metabolism + np.random.normal(0.0, 0.1)
         self.sight = parent.sight + np.random.normal(0.0, 0.1)
         self.sight_norm = self.sight / 200.0
         self.grate = parent.grate + np.random.normal(0.0, 0.1)
         self.hunger = parent.hunger + np.random.normal(0.0, 0.1)
         self.brate = parent.brate + np.random.normal(0.0, 0.1)
         self.drate = parent.drate + np.random.normal(0.0, 0.1)
     self.erate = self.size / 200
     self.stamina = self.stamina_cap * 5
     self.dtime = int(self.drate / (self.metabolism) * 1000)
     self.action_time = int(50 * self.stamina / self.metabolism)
     self.fat = 0.5
     if self.action_time < 50:
         self.action_time = 50
     a = t.timing(self.dtime, 0, 0)
     self.dtime = self.btime + a
     self.counter = 0
     #print(self.dtime.eons,self.dtime.days,self.dtime.ticks)
     self.normalize()
     self.px = x
     self.py = y
     self.velx = 0
     self.vely = 0
     self.ax = 0
     self.ay = 0
     self.wheel = r.roulette(self)
Example #3
0
async def on_reaction_add(reaction, user):
    global ddb_list

    if str(reaction.message.guild.id) != '322379168048349185':
        return

    channel_name = reaction.message.channel.name
    if channel_name not in ['blablabla', 'archive']:
        return

    if 'ddb' not in str(reaction).lower():
        return

    if reaction.message.id not in ddb_list['messages']:
        ddb_list['messages'][reaction.message.id] = []

    if user.name not in [
            'tama'
    ] and user.name in ddb_list['messages'][reaction.message.id]:
        return

    if user.name in ddb_list['timeouts'] and time.time(
    ) < ddb_list['timeouts'][user.name]:
        return

    ddb_list['messages'][reaction.message.id].append(user.name)
    ddb_list['timeouts'][user.name] = time.time() + 15

    muted_users = load("muted")
    if user.name in muted_users:
        return

    who = roulette.roulette(user.name)

    if who is not None:
        muted_time = 90
        if who is 'Fako':
            muted_time = muted_time * 2
            if user.name is 'Fako':
                muted_time = muted_time * 2
        maxTimeout = 0
        await reaction.message.channel.send(
            '[**Roulette DDB**] {0} ne peut plus poster pendant {1} secondes. ({2})'
            .format(who, muted_time, user.name))
        if who in muted_users:
            maxTimeout = muted_users[who]
        muted_users[who] = max(maxTimeout, time.time() + muted_time)
        save("muted", muted_users)
        ddb_list = {'messages': {}, 'timeouts': {}}
Example #4
0
    user_input = input(">>> ")

    if user_input == 'Dice' or user_input == 'dice':
        clear()
        dice()
        sleep(5)
        clear()
    elif user_input == 'Slots' or user_input == 'slots':
        clear()
        slots()
        sleep(5)
        clear()
    elif user_input == 'Roulette' or user_input == 'roulette':
        clear()
        roulette()
        sleep(5)
        clear()
    elif user_input == "21 points":
        game21()
        sleep(5)
        clear()
    elif user_input.lower() == "nvuti":
        nvuti()
        sleep(5)
        clear()
    elif user_input.lower() == "rgby":
        rgby()
        sleep(5)
        clear()
    elif user_input == 'Help' or user_input == 'help':
Example #5
0
import roulette
import os
import psutil
import gc
process = psutil.Process(os.getpid())
print(f'pid = {os.getpid()}')
start_rec = str(process.memory_info())

print(dir(roulette))

to_remove = 'tick'
to_update = 'boy'
initial_list = [(to_update, 1), ('hell', 2.5)]
additional_insert = [('fuckton', 2), (to_remove, 1), ('smelly', 1)]

randomizer = roulette.roulette(initial_list)

print(f'---before additional insert of {additional_insert}---')
for val, chance in randomizer:
    print(f'{val} has a chance of {chance}')

randomizer.insert_list(additional_insert)

print(
    f'---after additional insert of {additional_insert} before removing {to_remove}---'
)
for val, chance in randomizer:
    print(f'{val} has a chance of {chance}')

# randomizer.remove(to_remove)
del randomizer[to_remove]
Example #6
0
def probes(Targets, nEpochs, procNum, TargetsConc, ProbeConc, interval, Temp,
           popSize, nElite, pointmutProb, shiftmutProb, TargetCell):
    start_time = time.time()
    Probes = np.random.choice(4, (popSize, np.shape(Targets)[1])) + 1
    theprobes = np.zeros((0, np.shape(Targets)[1]))

    #Target들의 self secondary structure 에너지 계산.
    Ghp_target = np.zeros((1, np.shape(Targets)[0]))
    for i in range(np.shape(Targets)[0]):
        Seq1 = translate(Targets[i, :])
        rna_seqs = [Seq1[0]]

        G = float(
            nupack.mfe(rna_seqs,
                       ordering=None,
                       material='rna',
                       dangles='some',
                       T=37,
                       multi=0,
                       pseudo=False,
                       sodium=1.0,
                       magnesium=0.0,
                       degenerate=False)[0][1])
        Ghp_target[0, i] = G

    Khpt = Keq.Keq(Ghp_target, Temp)
    Khp_target = Khpt.keq()

    #Genetic algorithm 시작.
    iter = 0
    while iter < nEpochs:
        #Probe들의 self secondary structure 에너지 계산.
        procs = []
        pipe_list = []
        Ghp_probe = np.zeros((0, 1))
        for i in range(procNum):
            recv_end, send_end = multiprocessing.Pipe(False)

            Probe_part = Probes[int(i * (popSize / procNum)):int((i + 1) *
                                                                 (popSize /
                                                                  procNum)), :]

            proc = multiprocessing.Process(target=gibbs_single.Gibbs,
                                           args=(Probe_part, send_end))
            procs.append(proc)
            pipe_list.append(recv_end)
            proc.start()

        for proc in procs:
            proc.join()

        for x in pipe_list:
            result = np.array(x.recv())
            Ghp_probe = np.concatenate((Ghp_probe, result), axis=0)

        Khp = Keq.Keq(Ghp_probe, Temp)
        Khp_probe = Khp.keq()

        #Target과 Probe 사이의 결합 에너지 계산.
        procs = []
        pipe_list = []

        G_TargetProbe = np.zeros((0, np.shape(Targets)[0]))
        for i in range(procNum):
            recv_end, send_end = multiprocessing.Pipe(False)

            Probe_part = Probes[int(i * (popSize / procNum)):int((i + 1) *
                                                                 (popSize /
                                                                  procNum)), :]

            proc = multiprocessing.Process(target=gibbs_multi.Gibbs,
                                           args=(Probe_part, Targets,
                                                 send_end))
            procs.append(proc)
            pipe_list.append(recv_end)
            proc.start()

        for proc in procs:
            proc.join()

        for x in pipe_list:
            result = np.array(x.recv())
            G_TargetProbe = np.concatenate((G_TargetProbe, result), axis=0)

        K = Keq.Keq(G_TargetProbe, Temp)
        Keqs = K.keq()
        #print(Gibbs_list)

        #각 세포들의 hybridization yield 계산.
        Cp_list, Ct_list, Ct_hp, Cp_hp = cpt.Conc(Keqs, Khp_target, Khp_probe,
                                                  TargetsConc, ProbeConc)

        Cpts = np.zeros((np.shape(Probes)[0], np.shape(TargetsConc)[0]))
        for cell in range(np.shape(TargetsConc)[0]):
            for p in range(np.shape(Probes)[0]):
                Cpts[p, cell] = ProbeConc - Cp_list[p, cell] - Cp_hp[p, cell]

        #TargetCell의 Cpt 값의 상대 우위 계산.
        fitness = np.zeros((np.shape(Probes)[0], 1))
        for p in range(np.shape(Probes)[0]):
            TargetCpt = Cpts[p, int(TargetCell)]
            RestCpt = np.delete(Cpts[p, :], TargetCell).max()
            #print Cpts[p, :], np.delete(Cpts[p, :], TargetCell), TargetCpt, RestCpt
            fitness[p, 0] = TargetCpt - RestCpt
            #print(fitness[p,0], Cpts[p,int(TargetCell)].max(), TargetCpt, RestCpt)

        #print('f', fitness)

        theprobe = Probes[np.where(fitness == fitness.max())[0], :]

        # print(theprobe[0,:])

        elites = elite.elitism(nElite, Probes, fitness)
        #print(elites)
        #print np.shape(elites), np.shape(Probes)
        leftovers = roulette.roulette(elites, Probes, fitness)

        #print np.shape(Probes),  np.shape(leftovers)
        newPopulation = crossover.cross(leftovers,
                                        popSize - np.shape(elites)[0])
        newPopulation = pointmut.pointmut(newPopulation, pointmutProb)
        newPopulation = shiftmut.shiftmut(newPopulation, shiftmutProb)

        Probes = np.concatenate((elites, newPopulation), axis=0)

        #print(Ghp_probe)

        if iter % interval == 0:
            print 'Target =', str(TargetCell), '/ Iter =', iter
            print "End Time =", time.time() - start_time, 'Fitness =', round(
                fitness.max() / ProbeConc * 100, 3), "%"
            for t in range(np.shape(Targets)[0]):
                Seq1, Seq2 = translate2(theprobe[0], Targets[t, :])
                rna_seqs = [Seq1[0], Seq2[0]]
                print(
                    "MFE =", str(t),
                    nupack.mfe(rna_seqs,
                               ordering=None,
                               material='rna',
                               dangles='some',
                               T=37,
                               multi=0,
                               pseudo=False,
                               sodium=1.0,
                               magnesium=0.0,
                               degenerate=False),
                    Cpts[np.where(fitness == fitness.max())[0], t][0])

            theprobes = np.concatenate((theprobes, [theprobe[0]]), axis=0)
            #print(theprobes)

            #print(Cpts[np.where(fitness == fitness.max())[0], :])

        iter += 1

    return theprobes, fitness.max() / ProbeConc * 100