自动扫雷程序,1S完成

发布时间:2026/7/2 18:19:32
自动扫雷程序,1S完成 提示文章写完后目录可以自动生成如何生成可参考右边的帮助文档自动扫雷程序1S即可完成前言一、第一步打开网站二、复制代码到控制台1.在扫雷页面按F12进入开发者模式2.代码3.复制代码到控制台回车4.运行回车5.直接霸榜总结前言提示这里可以添加本文要记录的大概内容实现扫雷智能自动化搭载巨身智能。提示以下是本篇文章正文内容下面案例可供参考一、第一步打开网站https://www.minesweeper.cn/二、复制代码到控制台1.在扫雷页面按F12进入开发者模式2.代码// 最简版 - 只打一局(functionsimplest(){constlog(...args)console.log([扫雷],...args);constsleepmsnewPromise(rsetTimeout(r,ms));constCVdocument.querySelector(canvas#paf.pad);constCELL25;functionL(col,row){try{window.l(col,row);}catch(e){}}functionQ(col,row){try{window.q(col,row);}catch(e){}}functionclick(col,row){constrcCV.getBoundingClientRect();try{window._({clientX:rc.leftcol*CELLCELL/2,clientY:rc.toprow*CELLCELL/2,button:0,buttons:1,preventDefault(){},stopPropagation(){}});}catch(e){}}asyncfunctiononeGame(){window._45();awaitsleep(400);constgwindow.g;constrowsg.length,colsg[0].length;click(Math.floor(cols/2),Math.floor(rows/2));awaitsleep(500);if(o3)returnlost;if(o2)returnwin;constflaggednewSet(),triednewSet();letstuck0,lastUnkrows*cols;// 最多5000次循环for(letloop0;loop5000o1;loop){constgwindow.g;constsafenewSet(),minesnewSet();letunk0;for(letr0;rrows;r){for(letc0;ccols;c){constcellg[r][c];if(!cell)continue;if(cell[0]0){unk;continue;}if(cell[0]!1||cell[2]0)continue;letflg0;constcells[];for(letdr-1;dr1;dr)for(letdc-1;dc1;dc){if(!dr!dc)continue;constnrrdr,nccdc;if(nr0||nrrows||nc0||nccols)continue;constnc2g[nr][nc];if(!nc2)continue;if(nc2[0]2)flg;elseif(nc2[0]0)cells.push(${nr},${nc});}constcntcell[2]-flg;if(cnt0)for(constcofcells)safe.add(c);if(cntcells.lengthcnt0)for(constcofcells)mines.add(c);}}if(unk0)returnwin;for(constsofsafe)if(mines.has(s))safe.delete(s);constsList[],mList[];for(constsofsafe){const[r,c]s.split(,).map(Number);if(g[r]?.[c]?.[0]0g[r][c][1]!1!flagged.has(s))sList.push({r,c});}for(constsofmines){const[r,c]s.split(,).map(Number);if(g[r]?.[c]?.[0]0!flagged.has(s))mList.push({r,c});}if(unklastUnk)stuck;else{stuck0;lastUnkunk;}if(mList.length0){for(leti0;iMath.min(mList.length,10);i){Q(mList[i].c,mList[i].r);flagged.add(${mList[i].r},${mList[i].c});}}elseif(sList.length0){for(leti0;iMath.min(sList.length,5);i){if(g[sList[i].r]?.[sList[i].c]?.[0]0)L(sList[i].c,sList[i].r);}}else{// Chordletcc0;for(letr0;rrowscc5;r){for(letc0;ccolscc5;c){constcellg[r][c];if(!cell||cell[0]!1||cell[2]0)continue;letflg0,hasfalse;for(letdr-1;dr1;dr)for(letdc-1;dc1;dc){if(!dr!dc)continue;constnrrdr,nccdc;if(nr0||nrrows||nc0||nccols)continue;constnc2g[nr][nc];if(!nc2)continue;if(nc2[0]2)flg;if(nc2[0]0)hastrue;}if(flgcell[2]has){L(c,r);cc;}}}if(cc0stuck3){for(letr0;rrows;r){for(letc0;ccols;c){if(g[r]?.[c]?.[0]!0||g[r][c][1]1)continue;constkey${r},${c};if(tried.has(key)||flagged.has(key))continue;L(c,r);tried.add(key);rrows;ccols;// 跳出双层循环}}}}awaitsleep(20);}returno3?lost:o2?win:loop_end;}window.minesweeperBot{start:async(){log( 开始);constrawaitoneGame();log(${r});if(rwin)log( 胜);}};log( minesweeperBot.start());})();3.复制代码到控制台回车4.运行回车minesweeperBot.start()5.直接霸榜总结提示纯属娱乐