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算法 |