• 第二次结对编程作业


    1.链接

    同组同学博客地址:https://www.cnblogs.com/yuanzhengwen/p/11754531.html
    GitHub地址:https://github.com/AndreiIvanovichMihailov/031702217/tree/master/gambler

    2.分工

    于瀚翔:完成AI
    袁正闻:完成UI

    3.PSP表格

    PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟)
    Planning 计划 15 15
    Estimate 估计这个任务需要多少时间 5 5
    Development 开发 15 15
    Analysis 需求分析 (包括学习新技术) 180 300
    Design Spec 生成设计文档 5 5
    Design Review 设计复审 30 60
    Coding Standard 代码规范 (为目前的开发制定合适的规范) 10 10
    Design 具体设计 20 120
    Coding 具体编码 420 1200
    Code Review 代码复审 30 90
    Test 测试(自我测试,修改代码,提交修改) 10 60
    Reporting 报告 10 15
    Test Repor 测试报告 15 15
    Size Measurement 计算工作量 5 5
    Postmortem & Process Improvement Plan 事后总结, 并提出过程改进计划 10 10
    合计 780 1925

    4.解题思路描述与设计实现说明

    网络接口的使用

    def paixukey(elem):
    return elem.num
    url='http://www.revth.com:12300/auth/register2'
    form_data={
    "username": "Andrei",
    "password": "Mihailov",
    "student_number":"031702217",
    "student_password":"qwe123456789"
    }
    headers={
    "Content-Type":'application/json',
    }
    response=requests.post(url=url,headers=headers,data=json.dumps(form_data),verify=False)
    print(response.text)
    url = "http://api.revth.com/auth/login"
    headers = {
    "Content-Type":"application/json"
    }

    data = {

    "username": username,

    "password": password

    }

    payload = "{"username":"Andrei","password":"Mihailov"}"
    response = requests.request("POST", url, data=payload, headers=headers)
    print(response.text)

    p = re.compile(r'token":"(.+?)"')

    aaa = str(response.text)
    print(aaa)

    token = re.search('token": "(.+)"',aaa)

    p = re.compile(r'token":"(.+?)"')
    token = p.findall(aaa)[0]

    token = p.findall(response.text)[0]

    header = {
    "x-auth-token": token
    }
    print(token)
    def validate(header):

    url = 'http://api.revth.com/auth/validate'
    headers = {
        "x-auth-token": token111
    }
    response = requests.request("GET", url, headers=headers)
    print(response.text)
    

    def logout(header):
    url = 'http://api.revth.com/auth/logout'
    data = {}
    respond = requests.post(url, json=data).text
    print(respond)
    def openn(header):
    url = 'http://api.revth.com/game/open'
    header = str(header)
    headers = {'x-auth-token': header}
    data = {}
    response = requests.request("POST", url, headers=headers)
    return response
    def submit(idd, listt):
    url = "http://api.revth.com/game/submit"
    headers = {
    'content-type': "application/json",
    'x-auth-token': token
    }
    payload = "{"id":"
    payload = payload + str(idd)
    payload = payload + ","card":[""
    # payload = "{"id":"
    # payload=payload+str(idd)
    # payload=payload+"","card":[""
    if len(listt) == 1:
    payload = payload + str(listt[0])
    else:
    payload = payload + str(listt[0])
    payload = payload + "",""
    payload = payload + str(listt[1])
    payload = payload + "",""
    payload = payload + str(listt[2])
    payload = payload + ""]}"
    # print(payload)
    # dataa=str(data)
    response = requests.request("POST", url, data=payload, headers=headers)
    print(response.text)
    '''
    p = re.compile(r'token":"(.+?)"')
    token = p.findall(respond)[0]
    print(token)
    return token
    '''
    def history(header):
    u = 'http://api.revth.com/history'
    header = {
    "x-auth-token": token
    }
    response = requests.get(url=u, headers=header).text
    print(response)
    通过搜索教程和文档中已经给出的样例实现

    代码组织与内部实现设计

    思路就是把发来的牌组合一下,然后逐个得去判断牌型然后给一分数最后用分数最高的作为真正出的牌

    说明算法的关键与关键实现部分流程图

    5.关键代码的解释

    def score(list, m):
    if m == 5:
    f = tonghuashun(list)
    if f:
    return 150000+f700
    f = zhadan(list)
    if f:
    return 120000+f
    700
    f = hulu(list)
    if f:
    return 90000+f700
    f = tonghua(list)
    if f:
    return 70000+f
    0.000007
    f = shunzi(list)
    if f:
    return 60000+f700
    f = santiao(list)
    if f:
    return 50000+f
    700
    f = liandui(list)
    if f:
    return 40000+f7
    f = erdui(list)
    if f:
    return 30000+f
    7
    f = duizi(list)
    if f:
    return 20000+f100
    f = sanpai(list)
    if f:
    return 10000+f
    elif m == 3:
    """
    f = tonghuashun(list)
    if f:
    return 100000+f
    0.07
    f = tonghua(list)
    if f:
    return 70000+f0.07
    f = shunzi(list)
    if f:
    return 60000+f
    700
    """
    f = santiao(list)
    if f:
    return 50000+f700
    f = duizi(list)
    if f:
    return 20000+f
    100
    f = sanpai(list)
    if f:
    return 10000+100*f
    这是判断完牌型的评分环节,将最终决定到底将哪个排序输出

    6.性能改进及思路

    7.单元测试

    测试数据

    8.代码签入记录

    9.遇到的代码模块异常或结对困难及解决方法

    问题描述

    最初API接口不会用,网上搜索也没什么太大进展

    做过的尝试

    我去问别人已经写好的怎么写

    是否解决

    已解决

    有何收获

    学会了如何使用API

    10.评价队友

    值得学习的地方:速度很快,我后端还没有什么思路时前端就已经做好了,思路来的比我快。
    需要改进的地方:细节处需要改进,有些地方有小毛病需要回去修改

    11.学习进度

    第N周 新增代码(行) 累计代码(行) 本周学习耗时(时)
    9 700 2000 12
  • 相关阅读:
    聊聊WS-Federation
    用双十一的故事串起碎片的网络协议(上)
    责任链模式的使用-Netty ChannelPipeline和Mina IoFilterChain分析
    最小化局部边际的合并聚类算法(中篇)
    最小化局部边际的合并聚类算法(上篇)
    UVaLive 7371 Triangle (水题,判矩形)
    UVaLive 7372 Excellence (水题,贪心)
    POJ 3312 Mahershalalhashbaz, Nebuchadnezzar, and Billy Bob Benjamin Go to the Regionals (水题,贪心)
    UVa 1252 Twenty Questions (状压DP+记忆化搜索)
    UVa 10817 Headmaster's Headache (状压DP+记忆化搜索)
  • 原文地址:https://www.cnblogs.com/AndreiIvanovichMihailov/p/11754843.html
Copyright © 2020-2023  润新知