EE308_LAB2-2

只影清欢 只影清欢 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZU202201
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/608859318
MU STU ID and FZU STU ID20124147_832001108
GitHub Linkhttps://github.com/Ryan-pq/EE308-lab2-2
Video demo linkhttps://www.bilibili.com/video/BV12P4y117Vq/?share_source=copy_web

1.PSP form

Personal Software Process StagesEstimated time (minutes)real time (minutes)
Planning2040
- Estimate230270
Development3040
- Analysis4060
- Design Spec2030
- Design80120
- Coding110180
- Code Review2030
- Test2030
Reporting3060
Total620830

2.The key or difficult functions

This assignment shows the game in the form of small program. The production tool is wechat developer tool and the code is JavaScript.

1. Six dice produce random numbers

Due to the lack of knowledge of this language, I gradually understood it after consulting a series of materials and learning, and used for reference and modified part of the code. The final result is as follows:

const app = getApp()

Page({
    data: {
      txt:'点击摇一摇开始进行博饼',
      one_img:'https://img-blog.csdnimg.cn/20181116192114783.png',
      two_img: 'https://img-blog.csdnimg.cn/20181116192223207.png',
      three_img: 'https://img-blog.csdnimg.cn/20181116192249314.png',
      four_img: 'https://img-blog.csdnimg.cn/20181116192305231.png',
      five_img: 'https://img-blog.csdnimg.cn/20181116192320187.png',
      six_img: 'https://img-blog.csdnimg.cn/20181116192332897.png',
      flag:true,
      timer:null,
      msg:'摇一摇',
      total:0,


      arr:[
        'https://img-blog.csdnimg.cn/20181116192114783.png',
        'https://img-blog.csdnimg.cn/20181116192223207.png',
        'https://img-blog.csdnimg.cn/20181116192249314.png',
        'https://img-blog.csdnimg.cn/20181116192305231.png',
        'https://img-blog.csdnimg.cn/20181116192320187.png',
        'https://img-blog.csdnimg.cn/20181116192332897.png',
      ]
    },
    enter:function(event){
      let obj = this;
    var idx=0;
    var that=this;
    
     if(obj.data.flag==true){
         obj.data.timer = setInterval(function () {
     
          var one = that.randomNum(1, 6);
          var two = that.randomNum(1, 6);
          var three = that.randomNum(1, 6);
          var four = that.randomNum(1, 6);
          var five =that.randomNum(1, 6);
          var six = that.randomNum(1, 6);
  idx++;
  var tmp1=one;var tmp2=two;var tmp3=three; var tmp4=four ;var tmp5=five; var tmp6=six;         
  
  obj.setData({
            one_img:  one + ".png",
            two_img: two + ".png",
            three_img: three + ".png",
            four_img: four+ ".png",
            five_img:five+".png",
            six_img:six+".png",
            flag:false,
            msg:'等待中...',
  
           // total:18,
          })
  if(idx>20){
         

    
          clearInterval(obj.data.timer);
          obj.setData({
        txt:'',
               msg:'摇一摇',
               flag:true,
          })
    var NumberArr = [];
    NumberArr.push(tmp1,tmp2,tmp3,tmp4,tmp5,tmp6);
    var level = {
      one: '状元插金花',
      two: '满堂红', // 六子
      two1: '遍地锦',
      two2: '六勃黑',
      three: '五王', // 五子
      three1:'五子',
      four: '状元',
      five: '对堂',
      six: '三红',
      seven: '四进',
      eight: '二举',
      nine: '一秀',
      ten: '太遗憾啦'
   },
   this_level; 
  
    NumberArr.sort();
    var isfour = 0;
    for (var i = 0; i < NumberArr.length; i++) {
      if (NumberArr[i] == 4) {
          isfour = isfour + 1;
      }
  } 
  switch (isfour) {
    case 1:
        for (var i = 0; i < NumberArr.length; i++) {
            //存储当前相同的数量,判断是否为四进
            var ContrastArr = [];
            for (var j = 0; j < NumberArr.length; j++) {
                if (NumberArr[i] == NumberArr[j]) {
                    ContrastArr.push(NumberArr[j]);
                }
            }
        }
        // 等到上面遍历执行完再进行判断属于哪个级别
        if (ContrastArr.length === 4) {
            this_level = level.seven; //四进

            break;
        } else if (ContrastArr.length === 5) {
            this_level = level.three; //五王
            
            break;
        } else if (ContrastArr.length === 6) {
            this_level = level.two; //满堂红
           
            break;
        } else {
            // 判断一下,是 "对堂"" or ”一秀“,对堂就是顺子,123456,一秀就是一个只有4;
            var isContinuityArray = false;
            var array = NumberArr;
            var arrayCount = array.length;
            for (var i = 0; i < arrayCount; i++) {
                var currentArr = Number(array[i]) + 1;
                var nestArr = Number(array[i + 1]);
                if (i + 1 == arrayCount) {
                    currentArr = Number(array[i]);
                    nestArr = Number(array[i]);
                }
                if (currentArr != nestArr) {
                    isContinuityArray = false;
                    break;
                } else {
                    isContinuityArray = true;
                }
            }
            if (isContinuityArray) {
                this_level = level.five;
                
                break;
            } else {
                this_level = level.nine;
                
                
                break;
            }
        };
        break;
    case 2:
        for (var i = 0; i < NumberArr.length; i++) {
            var ContrastArr = [];
            for (var j = 0; j < NumberArr.length; j++) {
                if (NumberArr[i] == NumberArr[j]) {
                    ContrastArr.push(NumberArr[j]);
                }
            }
            // 判断是 4进 or 二举
            if (ContrastArr.length === 4) {
                this_level = level.seven;
               
                break;
            } else {
                this_level = level.eight;
                
            }
        };
        break;
    case 3:
        this_level = level.six;   
        break;
    case 4:
        // 判断是 "普通状元" or "状元插金花",普通就是4个四,插金花就是  4个四 + 2个1 ;
        var one = 0;
        for (var i = 0; i < NumberArr.length; i++) {
            if (NumberArr[i] === 1) {
                one = one + 1;
            }
        }
        if (one == 2) {
            this_level = level.one; // 插金花
            
        } else {
            this_level = level.four; //状元
           
        }
        break;
    case 5:
        this_level = level.three; // 五王
        
        break;
    case 6:
        this_level = level.two; //满堂红
        
        break;
    default:
        // 就是页面都没有四,来判断是否属于 “五子” 和 “六子” 和 “四进” 中的哪一种;
        for (var i = 0; i < NumberArr.length; i++) {
            var ContrastArr = [];
            for (var j = 0; j < NumberArr.length; j++) {
                if (NumberArr[i] == NumberArr[j]) {
                    ContrastArr.push(NumberArr[j]);
                }
            }
            if (ContrastArr.length === 4) {
                this_level = level.seven; //四进
               
                break;
            } else if (ContrastArr.length === 5) {
                this_level = level.three1; //五子
                
                break;
            } else if (ContrastArr.length === 6 && NumberArr[0] === 1) {
                this_level = level.two1; //遍地锦
                
                break;
            } else if (ContrastArr.length === 6 && NumberArr[0] === 2) {
                this_level = level.two2; //六勃黑
                
                break;
            } else {
                this_level = level.ten;
            }
        };
        break;  }


        that.setData({
          l:this_level,
          });
        }

        }, 50);}
      
    },
 

  randomNum: function (minNum, maxNum) {
    switch (arguments.length) {
      case 1:
        return parseInt(Math.random() * minNum + 1, 10);
        break;
      case 2:
        return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
        break;
      default:
        return 0;
    }
  } 

})

2. Judge the result of the dice roll

After a series of studies, I got a simple idea: When rolling dice, an array is used to store the number of the top points of each die, and it is judged in the switch(isfour) structure. The classification is based on the number of dice with 4 in the array. Then, under the current classification, if-elseif-else statements are used to list all possible results of the current number of 4. When comparing the options, a ContrastArr array was set to store dice with the same number of points. The array length was used to determine the number of dice with the same number of points in the set of dice.

3. Small program pop-up Settings

When we first contacted wechat developer tools, it took us a lot of time to click the button to pop up the popover and realize the mask effect. After referring to various popover operations of wechat mini program, we finally got the concrete realization

img

3.Experience and harvest in experiment

1.At the beginning of the project, I did not know the relevant knowledge of wechat small program development and did not know the programming language used. Therefore, to learn unfamiliar knowledge and write programs, at least more than half of the time was spent on learning new knowledge. This kind of time is short and the task is tight, and the situation of constantly learning new things is beneficial.
2.In the process of the experiment, we find that there are always mistakes between reality and imagination. We need to realize the final effect according to the actual situation and our own level.
3.This is the second pair assignment. Compared with the last assignment, this assignment is obviously much more difficult to realize. At the beginning of this assignment, I first agreed with my teammates on the core functions to be completed, and then I beautified and optimized the interface together. In the process of working in pairs, in line with the principle of being responsible for teammates and homework, I also avoided the phenomenon of being lazy and improved the efficiency of completion.

4.Summary

In this experiment, we not only need to complete more difficult tasks than before, but also need to learn the new language and software. The whole process is very difficult. At the same time, we also need to recognize the gap between the ideal and the reality, and some needs are very difficult to achieve and have to give up. There is something wrong with this experiment. At the same time, I understand the importance of cooperation. Only through mutual encouragement, help and learning can we complete this project.

...全文

相关推荐

EE-308 LAB4 final version.7z

这是本次实验的压缩包

晨起剪桃花

政府科技管理者如何高效评估科技成果的市场转化潜力?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

产业园区运营负责人如何实现园区内创新资源的智能配置?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

科技中介服务机构在为中小企业提供技术对接服务时,如何解决信息盲区与匹配低效问题?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

电力系统风储联合一次调频仿真模型(Simulink仿真实现)

内容概要:本文提供了“电力系统风储联合一次调频仿真模型”的Simulink仿真实现方案,系统性地构建了风电与储能系统协同参与电力系统一次频率调节的动态仿真模型。该模型深度融合风力发电的波动性特征与储能系统的快速响应能力,设计了联合调频控制策略,通过Simulink平台实现了对电网频率扰动的精细化仿真分析。内容涵盖风储功率协调分配、逆变器控制(如VSG、下垂控制)、中点电位平衡、正负序分离、电网前馈补偿等关键技术模块,重点考察控制逻辑架构、关键参数整定及系统在动态工况下的频率响应性能,旨在验证风储联合系统在提升低惯量电网频率稳定性和调频效能方面的可行性与优越性。; 适合人群:具备电力系统分析、自动控制理论及新能源并网技术基础,熟练掌握Simulink/MATLAB仿真工具,从事电力系统稳定控制、新能源集成、储能应用等方向研究的研究生、科研人员及电力行业工程技术人员。; 使用场景及目标:①深入探究风电与储能系统在电网一次调频中的协同控制机理与能量管理策略;②对比分析不同控制算法(如下垂控制、VSG、MPC等)对频率调节效果的影响;③支撑学术论文复现、科研项目仿真验证及新型电力系统工程方案的前期可行性研究。; 阅读建议:建议结合电力系统频率控制相关经典文献与最新研究成果,逐步调试模型中的控制参数,重点关注风储出力协调性、控制延时、响应速度及弱电网条件对整体调频性能的影响,推荐通过多场景对比仿真以深化对系统动态行为的理解。

荔枝科研社
评论
收藏 已收藏
分享
返回顶部