# 一、结对探索

## 1.1 队伍基本信息

032002128吕晨曦https://bbs.csdn.net/topics/608609752游戏流程设计+算法开发+搜集素材
032002123李若彤https://bbs.csdn.net/topics/608609466游戏框架设计+前端开发+原型设计

# 二、原型设计

## 2.3 原型作品链接

https://modao.cc/app/LAZxiCDrik8duDgh85p

# 三、编程实现

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

``````run (player_num, dice_num, add_chess_x, add_chess_y) {
this.flag = 0;
if (player_num == 1) {
for (let i = 0; i < 3; i++) {
}
}
if (this.matrix1_is_full()) {
if (this.count_matrix1_points() > this.count_matrix2_points()) {
this.flag = 1;
} else if (this.count_matrix1_points() == this.count_matrix2_points()) {
this.flag = 3;
} else {
this.flag = 2;
}
}
}
} else if (player_num == 2) {
for (let i = 0; i < 3; i++) {
}
}
if (this.matrix2_is_full()) {
if (this.count_matrix1_points() > this.count_matrix2_points()) {
this.flag = 1;
} else if (this.count_matrix1_points() == this.count_matrix2_points()) {
this.flag = 3;
} else {
this.flag = 2;
}
}
}
}
// flag == 0  继续比赛
// flag == 1  player1获胜
// flag == 2  player2获胜
// flag == 3  平局
return flag;
}
``````

``````robots_play() {
let max = -999999;
let x = 0;
let y = 0;
let Game1 = new GameBackEnd();
for (let j = 0; j < 3; j++) {
for (let i = 0; i < 3; i++) {
let obj1 = {
matrix1: GBE.matrix1,
matrix2: GBE.matrix2,
}
let obj2 = JSON.parse(JSON.stringify(obj1));
Game1.matrix1 = obj2.matrix1;
Game1.matrix2 = obj2.matrix2;
if (Game1.matrix1[i][j] == 0) {
Game1.run(1, dice, i, j);
}
if (Game1.count_matrix1_points() - Game1.count_matrix2_points() > max) {
max = Game1.count_matrix1_points() - Game1.count_matrix2_points();
x = i;
y = j;
}
}
}
GBE.run(1, dice, x, y);
}
``````

## 3.4 贴出重要的/有价值的代码片段并解释

``````clickPosition : function(a) {
if (gameflag) {
let x = a.currentTarget.dataset.column - 1;
let y = a.currentTarget.dataset.row - 1;
let num = a.currentTarget.dataset.num;
let avai = 0;
if (num == 1) {
if (GBE.matrix1[x][y] == 0)  {
avai = 1;
}
} else {
if (GBE.matrix2[x][y] == 0)  {
avai = 1;
}
}
if (avai) {
if (GBE.flag == 0 && playerTurnNum == num) {
GBE.run(num, dice, x, y);
this.setData({matrix1 : GBE.matrix1});
this.setData({matrix2 : GBE.matrix2});
setPmatrix();
this.setData({pmatrix1 : pm1});
this.setData({pmatrix2 : pm2});
this.setData({point1 : GBE.count_matrix1_points()});
this.setData({point2 : GBE.count_matrix2_points()});
if (playerTurnNum == 1) {
playerTurnNum = 2;
} else {
playerTurnNum = 1;
}
if (GBE.flag == 1) {
console.log("player1 win");
console.log(GBE.count_matrix1_points());
wx.redirectTo ({
url: '../lose/lose?bot=' + GBE.count_matrix1_points() + '&person=' + GBE.count_matrix2_points(),
})
gameflag = 0;
} else if (GBE.flag == 2) {
console.log("player2 win");
console.log(GBE.count_matrix2_points());
wx.redirectTo ({
url: '../win/win?bot=' + GBE.count_matrix1_points() + '&person=' + GBE.count_matrix2_points(),
})
gameflag = 0;
} else if (GBE.flag == 0) {
sleep(500);
dice = Math.floor(Math.random()*6 + 1);
this.setData({diceNum : png['rand']});
sleep(500);
this.setData({diceNum : png[dice]});
}
}
}
}
}
``````

``````let obj1 = {
matrix1: GBE.matrix1,
}
let obj2 = JSON.parse(JSON.stringify(obj1));
let m1 = obj2.matrix1;
GBE.run(num, dice, x, y);
this.setData({matrix1 : GBE.matrix1});
this.setData({matrix2 : GBE.matrix2});
setPmatrix();
this.setData({pmatrix2 : pm2});
let f = 0;
for (let i=0; i<3; i++) {
if (m1[x][i] != GBE.matrix1[x][i]) {
pm1[x][i] = "https://s2.loli.net/2022/10/12/mKyhTY8Npq3ZnFs.gif";
this.setData({pmatrix1 : pm1});
f = 1;
}
}
if (f == 1) {
sleep(1000);
}
``````

``````<--board1-->
<image class='{{bg1}}' src="https://s1.ax1x.com/2022/10/12/xUuETO.png" mode="aspectFill"></image>
<--board2-->
<image class='{{bg2}}' src="https://s1.ax1x.com/2022/10/12/xUuETO.png" mode="aspectFill"></image>
``````
``````.background1 {
opacity:0.5;
}
.background2 {
opacity:1;
}
``````
``````    this.setData({bg1 : "background2"});
this.setData({bg2 : "background1"});
``````

## 3.6 单元测试

``````// 小程序工具集
\$ npm i --save-dev miniprogram-simulate

// Jest测试框架
\$ npm i --save-dev jest
``````

``````{
sd

...

script: {

"test": "jest --coverage"

}

...

}
``````

``````module.exports = {

verbose: true,

modulePathIgnorePatterns: [

'<rootDir>/dist-wx/',

'<,rootDir>/node_modules/',

],

// 是否开启自动mock测试文件中导入的文件

automock: false,

testRunner: 'jasmine2',

// 测试文件执行前会先执行该文件，用来给Jest测试函数加代理从而收集测试用例

setupFilesAfterEnv: ['./node_modules/@tencent/dwt/dist/src/testbase/testbase.js'],

// 覆盖率报告依赖

reporters: [

'default',

'@tencent/dwt-reporter',

],

// 测试文件匹配规则

testMatch: [

'**/__test__/**/*.test.ts?(x)',

],

// 测试覆盖报告文件列表，下面是默认列表

coverageReporters: ['json', 'lcov', 'text', 'clover'],

// 全局变量配置

globals: {

NODE_ENV: 'test',

__wxConfig: {

global: {

window: {},

},

},

},

moduleNameMapper: {

'@/(.*)\$': '<rootDir>/\$1.ts',

},

setupFiles: ['<rootDir>/__test__/wx.ts'],

transform: {

'^.+\\.[jt]s?\$': 'ts-jest',

},

preset: 'ts-jest',

testEnvironment: 'jsdom',

collectCoverage: true,

coverageDirectory: './__test__/coverage',

coverageReporters: ['json-summary', 'text', 'lcov'],

coveragePathIgnorePatterns: [

'/node_modules/',

],

moduleNameMapper: {

'^@/(.*)\$': '<rootDir>/\$1',

},

coverageThreshold: {

global: {

branches: 50,

functions: 50,

lines: 50,

statements: 50,

},

},

};
``````

# 四、总结反思

## 4.1 本次任务的PSP表格

PSP2.1Personal Software Process Stages预估耗时（分钟）实际耗时（分钟）
Planning计划120240
· Estimate· 估计这个任务需要多少时间120240
Development开发916011300
· Analysis· 需求分析 (包括学习新技术)40005000
· Design Spec· 生成设计文档120240
· Design Review· 设计复审60120
· Coding Standard· 代码规范 (为目前的开发制定合适的规范)60200
· Design· 具体设计400500
· Coding· 具体编码40004000
· Code Review· 代码复审120240
· Test· 测试（自我测试，修改代码，提交修改）4001000
Reporting报告480500
· Test Report· 测试报告120240
· Size Measurement· 计算工作量60120
· Postmortem & Process Improvement Plan· 事后总结, 并提出过程改进计划120240
· 合计976012040

## 4.2 学习进度条（每周追加）

032002123李若彤：

1350035006464学会设计游戏框架，使用python建立web服务器框架，并实现互动功能
24500800070134学习了微信小游戏的使用，编写了游戏模型框架
350001300080216学习了微信小程序的使用，前端页面设计和编程

032002128吕晨曦：

1300030005656学习了强化学习、会使用numpy、pandas库
25000800070126学习了微信小程序的写法，熟练使用HTML、CSS、JS语言
350001300080206学习了PS等用于制作素材的软件，学习了如何上传微信小程序

032002123李若彤：

032002128吕晨曦：

## 4.5 结对编程作业心得体会

032002128李若彤：

032002128吕晨曦：

...全文
111 回复 打赏 收藏 转发到动态 举报

137

• 近7日
• 近30日
• 至今