Beispiel #1
0
def run(rot, fpr, cpr, dis, plot, fer, output, filename):
    (yn, En, Opy, MRTN_rate, Ns, NRN, PMY, Rg_min, Rg_max, FM,
     FC) = cal(rot, fpr, cpr, dis, fer)
    if output == "std":
        print(yn, En, Opy, MRTN_rate, Ns)
    elif output == "json":
        (xn, Yc, Yf, Yrtn, Ypmy, A, Xmin, Xmax) = get_plot_data(yn, fpr, cpr)
        with open(filename, "w") as f:
            f.write(
                json.dumps({
                    "yn": yn.tolist(),
                    "En": En,
                    "Opy": Opy,
                    "MRTN_rate": MRTN_rate,
                    "Ns": Ns,
                    "xn": xn.tolist(),
                    "Yc": Yc.tolist(),
                    "Yf": Yf.tolist(),
                    "Yrtn": Yrtn.tolist(),
                    "Ypmy": Ypmy.tolist(),
                    "A": A[0].tolist(),
                    "Xmin": Xmin.tolist(),
                    "Xmax": Xmax.tolist(),
                }))
    elif output == "plot":
        fig(plot, yn, En, Opy, cpr, fpr, Rg_min, Rg_max)
Beispiel #2
0
def get_data(driver, a):
    time.sleep(1)
    driver.find_element_by_link_text('教務系統').click()
    time.sleep(1)
    driver.find_element_by_link_text('學業成績查詢專區').click()
    time.sleep(1)

    url = 'https://aps-course.ntut.edu.tw/StuQuery/LoginSID.jsp&apOu=aa_003_LB&sso=big5&datetime1=1576904404080'
    client = requests.Session()
    res = client.get(url)

    url = 'https://aps-course.ntut.edu.tw/StuQuery/QryScore.jsp'
    driver.get(url)
    res = client.get(url)
    time.sleep(1)
    driver.find_element_by_xpath('/html/body/form/input[3]').click()  ##歷年
    time.sleep(1)

    source = driver.page_source

    #老柯
    soup2 = BeautifulSoup(source, "lxml")
    #print(soup2.text)
    ulist = []
    trs = soup2.find_all("tr")
    for tr in trs:
        ui = []
        for th in tr:
            ui.append(th.text.strip().replace(u'\u3000', u''))


##        print(ui)
        ulist.append(ui)
    col_name = ulist[0]
    need_list = []
    for i in ulist:
        if len(i) == 8:
            need_list.append(i)
    while col_name in need_list:
        need_list.remove(col_name)
    #print(need_list)

    b = calculate.cal(need_list, a)
    return b
def startGame():
    print(dialog["clear"])
    with open(jsonInventory, "r") as a:
        inventoryreset = json.load(a)
    skullnum1 = random.randint(0, 9)
    skullnum2 = random.randint(0, 9)
    skullnum3 = random.randint(0, 9)
    skullnum4 = random.randint(0, 9)
    skullnum5 = random.randint(0, 9)

    resetinventory = {
        "items": ["Key (Room 1)"],
        "randomItems": [],
        "unlocks": [],
        "locations": {
            "keylocation": "",
            "otherlocation": ""
        },
        "code": {
            "room1cabnet":
            random.randint(1000, 9999),
            "room2cabnet":
            random.randint(1000, 9999),
            "room3cabnet":
            f"{skullnum1} {skullnum2} {skullnum3} {skullnum4} {skullnum5}",
            "room4cabnet":
            f"{skullnum1}{skullnum2}{skullnum3}{skullnum4}{skullnum5}",
            "dif1num":
            f"{random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)}",
            "dif2num":
            f"{random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)}",
            "dif3num":
            f"{random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)} {random.randint(0, 9)}",
        },
        "timestart": int(time.time()),
        "otherdata": {
            "room2": [],
            "table": [],
            "difficulty": 0
        },
    }

    inventoryreset.update(resetinventory)

    with open(jsonInventory, "w") as f:
        json.dump(inventoryreset, f, indent=2)

    if data["Debug"]:
        print(dialog["debug"].format(
            mainCharacter,
            sideCharacter,
            antagonistCharacter,
            scene,
            roomName1,
            roomName2,
            roomName3,
            roomName4,
            roomName5,
            inventorySpace,
            specialItem,
            specialRoom,
            escapeDoorLocation,
        ))

    with open(jsonInventory, "r") as a:
        inventorydiffset = json.load(a)

    while True:

        difficultyinput = input(
            "-----------------------------------------\nSelect a difficulty(1, 2, 3)\n-----------------------------------------\n >#> "
        )
        if difficultyinput == "1":
            inventorydiffset["otherdata"]["difficulty"] = 1
            break
        elif difficultyinput == "2":
            inventorydiffset["otherdata"]["difficulty"] = 2
            break
        elif difficultyinput == "3":
            inventorydiffset["otherdata"]["difficulty"] = 3
            break
        else:
            print("Please Input a valid difficulty!")

    with open(jsonInventory, "w") as f:
        json.dump(inventorydiffset, f, indent=2)

    allcalc = cal()
    allposs = allcalc["allposs"]
    allvars = allcalc["allvar"]
    alllines = allcalc["lines"]
    allperc = allcalc["perc"]
    allpossf = f"{allposs:,}"
    allvarsf = f"{allvars:,}"
    alllinesf = f"{alllines:,}"
    print(dialog["clear"])
    print(dialog["start"].format(
        allpossf,
        allvarsf,
        alllinesf,
        inventoryreset["otherdata"]["difficulty"],
        allperc,
        allpossf,
        allvarsf,
        alllinesf,
    ))
    input("\nPress Enter to start...")
    global Start
    Start = time.time()
    print(dialog["clear"])
    print(dialog["dialog1.0"])
    input()
    print(dialog["clear"])
    print(dialog["dialog1.1"])
    input()
    print(dialog["clear"])
    print(dialog["dialog1.2"])
    input()
    print(dialog["clear"])
    print(dialog["dialog1.3"].format(mainCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.4"])
    input()
    print(dialog["clear"])
    print(dialog["dialog1.5"].format(mainCharacter, mainCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.6"].format(sideCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.7"].format(mainCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.8"].format(sideCharacter, scene))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.9"].format(mainCharacter, scene))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.10"].format(sideCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.11"].format(mainCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.12"].format(sideCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.13"].format(mainCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.14"])
    input()
    print(dialog["clear"])
    print(dialog["dialog1.15"].format(sideCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.16"].format(sideCharacter))
    input()
    print(dialog["clear"])
    print(dialog["dialog1.17"].format(sideCharacter))
    input()
    print(dialog["clear"])
    corridor()
Beispiel #4
0
# AA00002中length = 300
# AB00006中length = 400
# AD00003中length = 500
# AD00013中length = 300
# AD00053中length = 700
# AD00083中length = 300
# AD00419中length = 300
# AF00098中length = 300
# AF00131中length = 100
# AF00373中length = 100

for i in range(len(position) - 1):
    if position[i + 1][2] - position[i][2] > 30 or abs(
            position[i][0] - position[i + 1][0]) + abs(
                position[i][1] - position[i + 1][1]) > 0.1:
        if len(l) > length:
            sum += write.writer(file_path, final_data, l)
            if num < line:
                sum += write.exchange(file_path, final_data, stop_point, i,
                                      num)
                num += 1
        l = []
    else:
        l.append(position[i])

write.map(final_data, cal.avg(lat), cal.avg(lng),
          os.path.join(save_final_map_path, save_final_map_name))

#输出每段路程的里程、平均速度和急加减速次数
cal.cal(final_data)
def outcome_list(expression, inverted_index):  # 根据表达式和倒排索引表产生结果list
    postfix_list = infix2postfix.infix2postfix(expression)
    outcome = calculate.cal(postfix_list, inverted_index)
    return outcome