结对编程作业

一、项目及分工

我的博客地址:https://www.cnblogs.com/Wifi-yang/
队友:https://www.cnblogs.com/cpandbb/
项目地址:https://github.com/WiFi-yang/031804133/tree/master/结对

原型设计 游戏 AI 解题及改良
杨锋夏
黄纯朴

二、原型设计

设计说明:
这次结对编程,我们看了很多的数字华容道跟拼图游戏:

还有:

我们设计的最终的是这样的:



原型设计工具:墨刀

网络接口的使用

def start(uuid):
    url = 'http://47.102.118.1:8089/api/challenge/start/' + uuid
    teamdata = {
        "teamid": 58,
        "token": "e422a424-0ab4-4b25-b973-923eb887ae42"
    }
    r = requests.post(url, json=teamdata)
    r_json = r.json()
    print(r_json)
    chanceleft = r_json['chanceleft']
    img_str = r_json['data']['img']
    step = r_json['data']['step']
    swap = r_json['data']['swap']
    uuid = r_json['uuid']
    img_b64decode = base64.b64decode(img_str)  # base64解码
    file = open('test.jpg', 'wb')
    file.write(img_b64decode)
    file.close()
    image = io.BytesIO(img_b64decode)
    img = Image.open(image)
    return img, step, swap, uuid
def up_data(uuid, answer):
    url_up = 'http://47.102.118.1:8089/api/challenge/submit'
    updata = {
        "uuid": uuid,
        "teamid": 58,
        "token": "e422a424-0ab4-4b25-b973-923eb887ae42",
        "answer": {
            "operations": answer,
            "swap": []
        }
    }
    r_up = requests.post(url_up, json=updata)
    r_up_json = r_up.json()
    print(r_up_json)

找原图

def ergodic_file():
    org_img_folder = './org'
    # 检索文件
    imglist = getFileList('C:/Users/Administrator/软工/无框字符', [], 'jpg')
    print('本次执行检索到 ' + str(len(imglist)) + ' 张图像\n')
    print(imglist)
    z = 0
    save_path = 'C:/Users/Administrator/软工/imgas'
    for imgpath in imglist:  # 每个图片都遍历一次 并开始进行对比操作
        img_temp = Image.open(imgpath)
        get_img(save_path, img_temp)
        count_1 = 0
        stop_flag = 0
        print(imgpath)
        for i in range(9):
            for j in range(9):
                imag1_path = 'C:/Users/Administrator/软工/imgs/%s.jpg' % i
                imag2_path = 'C:/Users/Administrator/软工/imgas/%s.jpg' % j
                ssim_text = image_similarity(imag1_path, imag2_path)
                if ssim_text == 1:
                    count_1 = count_1 + 1

遇到的困难:
由于进度较慢,还没来得及写AI

PSP:

|PSP(二人合计)|Personal Software Process Stages|预估耗时(分钟)|实际耗时(分钟)|
|----|-----|---------|---------|---------|
|Planning|计划|40|40|
|Estimate|估计这个任务需要多少时间|60|60|
|Development|开发|1500|900|
|Analysis|需求分析 (包括学习新技术)|600|900|
|Coding Standard|代码规范 (为目前的开发制定合适的规范)|120|60|
|Coding|具体编码|600|900|Code Review|代码复审|90|80|
没有做完就不做统计了。。

posted @ 2020-10-19 22:56  我是WiFi靠近我!  阅读(79)  评论(0编辑  收藏  举报