PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
---|---|---|---|
Planning | 计划 | 100 | 120 |
· Estimate | · 估计这个任务须要多少时间 | 100 | 120 |
Development | 开发 | 2700 | 3300 |
· Analysis | · 需求分析 (包括学习新技术) | 1200 | 1500 |
· Design Spec | · 生成设计文档 | 120 | 120 |
· Design Review | · 设计复审 | 60 | 60 |
· Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 180 | 180 |
· Design | · 具体设计 | 180 | 180 |
· Coding | · 具体编码 | 600 | 900 |
· Code Review | · 代码复审 | 90 | 90 |
· Test | · 测试(自我测试,修改代码,提交修改) | 60 | 60 |
Reporting | 报告 | 60 | 90 |
· Test Repor | · 测试报告 | 0 | 0 |
· Size Measurement | · 计算工做量 | 60 | 60 |
· Postmortem & Process Improvement Plan | · 过后总结, 并提出过程改进计划 | 90 | 60 |
· 合计 | 2800 | 3420 |
PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
---|---|---|---|
Planning | 计划 | 60 | 90 |
· Estimate | · 估计这个任务须要多少时间 | 60 | 90 |
Development | 开发 | 1020 | 1290 |
· Analysis | · 需求分析 (包括学习新技术) | 120 | 180 |
· Design Spec | · 生成设计文档 | 60 | 30 |
· Design Review | · 设计复审 | 30 | 60 |
· Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 30 | 30 |
· Design | · 具体设计 | 240 | 360 |
· Coding | · 具体编码 | 360 | 420 |
· Code Review | · 代码复审 | 60 | 30 |
· Test | · 测试(自我测试,修改代码,提交修改) | 120 | 180 |
Reporting | 报告 | 120 | 120 |
· Test Repor | · 测试报告 | 30 | 30 |
· Size Measurement | · 计算工做量 | 30 | 30 |
· Postmortem & Process Improvement Plan | · 过后总结, 并提出过程改进计划 | 60 | 60 |
· 合计 | 1200 | 1500 |
function my() { if(document.getElementById("username").value=="" || document.getElementById("password").value=="") {alert("帐号和密码不能为空");return ;} else{ var data = JSON.stringify({ "username": document.getElementById("username").value, "password": document.getElementById("password").value }); var xhr = new XMLHttpRequest(); xhr.onreadystatechange=function(){ if(xhr.readyState==4&&xhr.status==200){ var json=JSON.parse(xhr.responseText); alert("登录成功"); localStorage.removeItem("token"); localStorage.removeItem("user_id"); localStorage.setItem("token",json.data.token); localStorage.setItem("user_id",json.data.user_id); window.location.href='start(1).html'; console.log(xhr.responseText); } } xhr.open("POST", "https://api.shisanshui.rtxux.xyz/auth/login",true); xhr.setRequestHeader("content-type", "application/json"); xhr.send(data); } }
注销登陆接口(UI部分)css
function my() { var xhr=new XMLHttpRequest(); xhr.onreadystatechange=function () { if(xhr.readyState==4&&xhr.status==200){ alert(xhr.responseText); window.location.href="index.html"; } } xhr.open("POST", "https://api.shisanshui.rtxux.xyz/auth/logout"); xhr.setRequestHeader("x-auth-token", localStorage.getItem("token")); xhr.send(); }
历史详情接口(UI部分)html
function my(){ dec(); var obj; var xhr = new XMLHttpRequest(); var num=document.getElementById("number").value; xhr.onreadystatechange=function(){ if(xhr.readyState==4){ obj=JSON.parse(xhr.responseText); if(xhr.status==200){ function getJson(json){ var l=0; for(var j in json.data.detail){ document.getElementById("demo").innerHTML+='<tr><td style="width: 13%">'+json.data.detail [l].player_id+'</td><td style="width: 17%;text-align: center">'+json.data.detail [l].name+'</td><td style="width: 10%">'+json.data.detail [l].score+'</td><td style="width: 60%">'+json.data.detail [l].card+'</td></tr>'; l++; } } getJson(obj); } else if(obj.status==2004){alert("战局不存在或已结束");} else if(obj.status==3001){alert("战局不存在或未结束");} } } xhr.open("GET", "https://api.shisanshui.rtxux.xyz/history/"+num,true); xhr.setRequestHeader("x-auth-token", localStorage.getItem("token")); xhr.send(); }
AI:api请求使用的是python里的request库
如下贴出net_api.py文件中的主要函数python
import requests import cards_division url='https://api.shisanshui.rtxux.xyz' cards_list = [] max_list = [] def sign_in(username,password): def register(username,password): def logout(): def new_game_and_play(): def get_rank(): def get_history_list(limit,page): def get_history_details(game_id): if __name__=='__main__':
代码组织与内部实现设计(类图)(6分)
咱们使用的是纯贪心算法,先出后墩和中墩代码,以后再根据后中墩牌型的类型在避免倒水的状况下出头墩,在后中墩代码实现过程当中尽可能使牌面平衡,三墩牌面尽可能都大git
说明算法的关键与关键实现部分流程图(6分)
github
算法关键:算法
# 获取牌型桶 def getBucket(arr_card): # 统计同数值花色的多少并统计同花色数值的多少 def CardVal(cards_): # 判断同花顺 判断同花个数 在判断有无联顺much个 def CardsTHS(cards_, much): # 后墩,中墩出牌函数 def judge5(_post, _pai, card): # 进行头墩出牌函数 def judge3(_post1, _post2, _pai, card, ty1, ty2): # 将本身处理好的代码进行转换发送至服务端 def zhuanCards(chu, much): # 出牌主函数 def divide_cards(cards_list):
var xhr = new XMLHttpRequest(); xhr.onreadystatechange=function(){ if(xhr.readyState==4&&xhr.status==200){ var json=JSON.parse(xhr.responseText); alert(xhr.responseText); localStorage.removeItem("token"); localStorage.removeItem("user_id"); localStorage.setItem("token",json.data.token); localStorage.setItem("user_id",json.data.user_id); window.location.href='start(1).html'; console.log(xhr.responseText); } } xhr.open("POST", "https://api.shisanshui.rtxux.xyz/auth/login",true); xhr.setRequestHeader("content-type", "application/json"); xhr.send(data);
AI:
这里贴出比较有特点的片断,为方便阅读先解释以下:
在这个片断前,咱们先表达一下处理从服务器接收来的字符串咱们是如何处理的:1.咱们将字符串中的花色符号所有转换为数字1-4;2.将数值部分提取出来;3.计算公式:牌=值*4+花色。存储方面:创建二维数组,不一样行表明花色(四行),不一样列表明数值(13列)。
至于讲到普通出牌的判断,咳咳咳咱们用的是鸵鸟算法。哈哈哈接下来po出一些片断:
idea:是将同种花色的牌数量存储在每一行的最后一位;将同大小数值的牌数存储在每一列的最后一位。json
# 统计同数值花色的多少并统计同花色数值的多少 def CardVal(cards_): for i in range(2, 15): sum = 0 for j in range(1, 5): if cards_[j][i] == 1: sum = sum + 1 cards_[5][i] = sum for i in range(1, 5): sum = 0 for j in range(2, 15): if cards_[i][j] == 1: sum = sum + 1 cards_[i][15] = sum return cards_
这里po出判断同花顺的函数,
idea:much表明的是想要判断3同花仍是5同花,直接判断每行最后一位是否足够much,若足够就往回推。后端
# 判断同花顺 判断同花个数 在判断有无联顺much个 def CardsTHS(cards_, much): for i in range(1, 5): if cards_[i][15] >= much: for j in range(14, much, -1): count = 0 for k in range(much): if cards_a[i][j - k] == 1: count = count + 1 if count == much: return i, j return 0, 0
这五个单元测试是在实现算法的时候,经过本地输入输出来测试咱们代码的可行性,测试了判断五张牌的函数Judge5和Judge3,def CardsTHS上文有展现一部分。这样构造的思路是为了测试,五张中的炸弹、同花、葫芦等这种咱们在编写函数的时候比较担忧的点,以及还有三张中的同花,且经过测试来查看是否会产生倒水。api
第N周 | 新增代码(行) | 累计代码(行) | 本周学习耗时(小时) | 累计学习耗时(小时) | 重要成长 |
---|---|---|---|---|---|
1 | 0 | 0 | 5 | 5 | 熟悉使用axure,并利用axure设计了产品原型 |
2 | 0 | 0 | 10 | 15 | 简单了解了html,css,和js |
3 | 500 | 500 | 15 | 30 | 学习了html,css,js语言及其使用,开始作网页页面设计,作出了网页雏形 |
4 | 300 | 800 | 27 | 57 | 主要学习了接口的使用,以及规范代码,肯定最后的布局 |
第N周 | 新增代码(行) | 累计代码(行) | 本周学习耗时(小时) | 累计学习耗时(小时) | 重要成长 |
---|---|---|---|---|---|
1 | 0 | 0 | 5 | 5 | 学了一点js,学习使用axure,尝试作了第一个原型模型 |
1 | 0 | 0 | 5 | 5 | 学习一些JavaScript知识 |
2 | 200 | 200 | 5 | 10 | 学习一些接口知识,理清楚出牌思路 |
3 | 400 | 600 | 10 | 25 | 实现出牌算法,并对一些问题进行修复,学到了不少python算法 |