def main():
    """ Load configurations for the game """

    # create and load dictionary of points
    if not os.path.isfile(WORDSDICT):
        print "Generating dictionary..."
        create_dict()

    try:
        wordPoints = load_dict()

    except:
        print("Could not load the dictionary.")
        sys.exit()
    ''' get the list '''
    letters = raw_input("Type the letters: ")
    if len(letters) > 15:
        return "Hand should be at most 15 letters."
    handCombination = generate_combination(letters)
    """ show sorterd, with point """
    valid = []
    for comb in handCombination:
        if comb in wordPoints.keys():
            valid.append([comb, wordPoints[comb]])

    print "Possible words are:"
    for w in sorted(valid, reverse=True):
        print w[0] + " - Points: " + str(w[1])
Exemple #2
0
def main():

    """ Load configurations for the game """

    # create and load dictionary of points
    if not os.path.isfile(WORDSDICT):
        print "Generating dictionary..."
        create_dict()

    try:
        wordPoints = load_dict()

    except:
        print ("Could not load the dictionary.")
        sys.exit()

    """ get the list """
    letters = raw_input("Type the letters: ")
    if len(letters) > 15:
        return "Hand should be at most 15 letters."
    handCombination = generate_combination(letters)

    """ show sorterd, with point """
    valid = []
    for comb in handCombination:
        if comb in wordPoints.keys():
            valid.append([comb, wordPoints[comb]])

    print "Possible words are:"
    for w in sorted(valid, reverse=True):
        print w[0] + " - Points: " + str(w[1])
Exemple #3
0
def main():

    greetings()

    """ Load configurations for the game """

    # create and load dictionary of points
    if not os.path.isfile(WORDSDICT):
        create_dict()

    try:
        wordPoints = load_dict()
    except:
        return "Could not load the dictionary."

    try:
        lettersGame = create_list_letters()
    except:
        return "Could not create list of letters."

    """ set game variables """
    piecesLeft = len(lettersGame)
    numberOfPiecesHand = 5
    lettersDict = LETTERS

    lettersPC = ""
    pointsPC = 0
    wordsPC = []

    lettersHuman = ""
    pointsHuman = 0
    wordsHuman = []

    """ Game Loop """
    while piecesLeft >= 2 * numberOfPiecesHand:

        # computer's turn
        print("\n--> Computer's Turn:")
        points, word, lettersPC, lettersDict = computerTurn(
            wordPoints, lettersGame, numberOfPiecesHand, lettersDict, lettersPC
        )

        pointsPC += points
        wordsPC.append(word)
        printStatus(word, str(points), str(pointsPC))

        # human's turn
        print("\n--> Your Turn:")
        points, word, lettersHuman, lettersDict = humanTurn(
            wordPoints, lettersGame, numberOfPiecesHand, lettersDict, lettersHuman
        )

        pointsHuman += points
        wordsHuman.append(word)
        printStatus(word, str(points), str(pointsHuman))

        break

    """ Game Finalization """
    goodbye(str(pointsHuman), str(pointsPC), wordsHuman, wordsPC)
Exemple #4
0
def main():

    greetings()
    """ Load configurations for the game """

    # create and load dictionary of points
    if not os.path.isfile(WORDSDICT):
        create_dict()

    try:
        wordPoints = load_dict()
    except:
        return "Could not load the dictionary."

    try:
        lettersGame = create_list_letters()
    except:
        return "Could not create list of letters."
    """ set game variables """
    piecesLeft = len(lettersGame)
    numberOfPiecesHand = 5
    lettersDict = LETTERS

    lettersPC = ""
    pointsPC = 0
    wordsPC = []

    lettersHuman = ""
    pointsHuman = 0
    wordsHuman = []
    """ Game Loop """
    while piecesLeft >= 2 * numberOfPiecesHand:

        # computer's turn
        print("\n--> Computer's Turn:")
        points, word, lettersPC, lettersDict =  computerTurn(wordPoints, lettersGame, \
                            numberOfPiecesHand, lettersDict, lettersPC)

        pointsPC += points
        wordsPC.append(word)
        printStatus(word, str(points), str(pointsPC))

        # human's turn
        print("\n--> Your Turn:")
        points, word, lettersHuman, lettersDict =  humanTurn(wordPoints, lettersGame, \
                            numberOfPiecesHand, lettersDict, lettersHuman)

        pointsHuman += points
        wordsHuman.append(word)
        printStatus(word, str(points), str(pointsHuman))

        break
    """ Game Finalization """
    goodbye(str(pointsHuman), str(pointsPC), wordsHuman, wordsPC)
Exemple #5
0
N_list = [33, 47, 87]
target_dir = '/nu_compare'
setup.checkdir(target_dir)

search_dir = './'+model+'_info/nu'
anchor = setup.find_anchor()
fs = []
for N in N_list:
    if int(sys.argv[3]) == 1:
        root, filenames = setup.gtfpath(search_dir, '^.*_(.*)rom_'+str(N)+'nb_ic.*_'+str(int(anchor-90))+'_nu$')
    elif int(sys.argv[3]) > 1:
        root, filenames = setup.gtfpath(search_dir, '^.*_(.*)rom_'+str(N)+'nb_zero.*_'+str(int(anchor-90))+'_*nu$')
    fs.append(filenames.pop())

files_dict = setup.create_dict(fs, '^.*_([0-9]*)nb_.*$')
dict_final = sorted(files_dict.items(), key=operator.itemgetter(0))

color_ctr = 0

i = 0
tpath = './nu/'

fig, ax = plt.subplots(1, tight_layout=True)
# get the FOM data
filename = '../../../../fom_nuss/nuss_fom_'+str(int(anchor))
data = mypostpro.read_nuss(filename)
data[:, 2] = data[:, 2]/40
idx1 = mypostpro.find_nearest(data[:, 0], 0)
idx2 = mypostpro.find_nearest(data[:, 0], 1000)
avgidx1 = mypostpro.find_nearest(data[:, 0], 501)
Exemple #6
0
mode = str(sys.argv[5])
print("---------------------------------------------")

target_dir = '/vel_dual_norm/'
setup.checkdir(target_dir)

search_dir = './' + model + '_info/vel_dual_norm'
if model == 'all':
    root, filenames = setup.gtfpath(search_dir, '^.*_' + N + 'nb_.*$')
else:
    root, filenames = setup.gtfpath(
        search_dir, '^.*_' + N + 'nb_ic_h10_(?!.*-90|.*-80|.*-70).*$')
if model == 'l-rom' or model == 'l-rom_df':
    fd = str(sys.argv[5])
    if T0 == 1:
        files_dict = setup.create_dict(filenames,
                                       '^.*_ic_h10_(-?\d+)_' + fd + '.*$')
    elif T0 >= 1:
        files_dict = setup.create_dict(filenames,
                                       '^.*_zero_h10_(-?\d+)_' + fd + '.*$')
else:
    if T0 == 1:
        files_dict = setup.create_dict(filenames, '^.*_ic_h10_(-?\d+)_.*$')
    elif T0 >= 1:
        files_dict = setup.create_dict(filenames, '^.*_zero_h10_(-?\d+)_.*$')
dict_final = sorted(files_dict.items(), key=operator.itemgetter(0))

color_ctr = 0
tpath = root + '/'

erri = []
angles = []
Exemple #7
0
print("---------------------------------------------")

target_dir = '/mabserr/'
setup.checkdir(target_dir)

search_dir = './' + model + '_info/mabserr'
if mode == 'all':
    root, filenames = setup.gtfpath(search_dir, '^.*_' + N + 'nb_.*$')
else:
    root, filenames = setup.gtfpath(
        search_dir, '^.*_' + N + 'nb_.*_h10_(?!.*-90|.*-80|.*-70).*$')
if model == 'l-rom' or model == 'l-rom_df':
    fd = str(sys.argv[6])
    if T0 == 1:
        #       files_dict = setup.create_dict(filenames, '^.*_ic_h10_(-?\d+)_'+fd+'.*$')
        files_dict = setup.create_dict(
            filenames, '^.*_ic_h10_.*_(-?\d+)_' + fd + '_mabserr$')
    elif T0 >= 1:
        #       files_dict = setup.create_dict(filenames, '^.*_zero_h10_(-?\d+)_'+fd+'.*$')
        files_dict = setup.create_dict(
            filenames, '^.*_zero_h10_.*_(-?\d+)_' + fd + '_mabserr$')
else:
    if T0 == 1:
        #       files_dict = setup.create_dict(filenames, '^.*_ic_h10_(-?\d+)_.*$')
        files_dict = setup.create_dict(filenames,
                                       '^.*_ic_h10_.*_(-?\d+)_mabserr$')
    elif T0 >= 1:
        #       files_dict = setup.create_dict(filenames, '^.*_zero_h10_(-?\d+)_.*$')
        files_dict = setup.create_dict(filenames,
                                       '^.*_zero_h10_.*_(-?\d+)_mabserr$')
dict_final = sorted(files_dict.items(), key=operator.itemgetter(0))
os.chdir(str(sys.argv[1]))
model = str(sys.argv[2])
N = str(sys.argv[3])
T0 = int(sys.argv[4])
print("---------------------------------------------")

angles = np.linspace(0, 180, 19, dtype=int)
for angle in angles:
    target_dir = '/dual_norm/'
    setup.checkdir(target_dir)

    search_dir = './' + model + '_info/dual_norm'
    root, filenames = setup.gtfpath(search_dir, '^.*_' + N + 'nb_.*$')
    if T0 == 1:
        files_dict = setup.create_dict(
            filenames, '^.*_ic_h10_' + str(int(angle - 90)) +
            '_(-?[+-]?([0-9]*[.])?[0-9]+)_dual_norm$')
    elif T0 >= 1:
        files_dict = setup.create_dict(
            filenames, '^.*_zero_h10_' + str(int(angle - 90)) +
            '_(-?[+-]?([0-9]*[.])?[0-9]+)_dual_norm$')
    dict_final = sorted(files_dict.items(), key=operator.itemgetter(0))

    color_ctr = 0
    tpath = root + '/'

    erri = []
    fws = []
    for fw, fnames in dict_final:
        for fname in fnames:
            data = reader.reader(fname)
Exemple #9
0
print("---------------------------------------------")
print("This is the name of the program:", sys.argv[0])
print("Argument List:", str(sys.argv))
os.chdir(str(sys.argv[1]))
model = str(sys.argv[2])
N = str(sys.argv[3])
T0 = int(sys.argv[4])
print("---------------------------------------------")

target_dir = '/abserr/'
setup.checkdir(target_dir)

search_dir = './' + model + '_info/rom_abserr'
root, filenames = setup.gtfpath(search_dir, '^.*_' + N + 'nb_.*$')
if T0 == 1:
    files_dict = setup.create_dict(filenames, '^.*_ic_h10_(.*\d+)_.*$')
elif T0 >= 1:
    files_dict = setup.create_dict(filenames, '^.*_zero_h10_(.*\d+)_.*$')
dict_final = sorted(files_dict.items(), key=operator.itemgetter(0))

color_ctr = 0
tpath = root + '/'

angles = []
abserr_rom = []
abserr_proj = []
for angle, fnames in dict_final:
    for fname in fnames:
        solver = checker.rom_checker(fname, '^.*_(.*)rom_.*$')
        data = reader.reader(fname)
        data = np.array(data).astype(np.float64)
Exemple #10
0
print("This is the name of the program:", sys.argv[0])
print("Argument List:", str(sys.argv))
os.chdir(str(sys.argv[1]))
model = str(sys.argv[2])
N = str(sys.argv[3])
T0 = int(sys.argv[4])
angle = int(sys.argv[5])
print("---------------------------------------------")

target_dir = '/dual_norm/'
setup.checkdir(target_dir)

search_dir = './' + model + '_info/dual_norm'
root, filenames = setup.gtfpath(search_dir, '^.*_' + N + 'nb_.*$')
if T0 == 1:
    files_dict = setup.create_dict(filenames,
                                   '^.*_ic_h10_.*_(\dp\d+)_dual_norm$')
elif T0 >= 1:
    files_dict = setup.create_dict(filenames,
                                   '^.*_zero_h10_.*_(\dp\d+)_dual_norm$')
dict_final = sorted(files_dict.items(), key=operator.itemgetter(0))

color_ctr = 0
tpath = root + '/'

erri = []
fws = []
for fw, fnames in dict_final:
    for fname in fnames:
        data = reader.reader(fname)
        if not data:
            data = 1e8
os.chdir(str(sys.argv[1]))
model = str(sys.argv[2])
N = str(sys.argv[3])
T0 = int(sys.argv[4])
angle = int(sys.argv[5])
print("---------------------------------------------")

target_dir = '/mrelerr/'
setup.checkdir(target_dir)
f1 = 1
f2 = 100

search_dir = './' + model + '_info/mrelerr'
root, filenames = setup.gtfpath(search_dir, '^.*_' + N + 'nb_.*$')
if T0 == 1:
    files_dict = setup.create_dict(filenames,
                                   '^.*_ic_h10_.*_(\dp\d+)_mrelerr$')
elif T0 >= 1:
    files_dict = setup.create_dict(filenames,
                                   '^.*_zero_h10_.*_(\dp\d+)_mrelerr$')
dict_final = sorted(files_dict.items(), key=operator.itemgetter(0))

color_ctr = 0
tpath = root + '/'

fws = []
mrelerr_proj = []
mrelerr_rom = []
for fw, fnames in dict_final:
    for fname in fnames:
        data = reader.reader(fname)
        if not data: