cocos 寫 連連看 小游戲主要邏輯(Ts編寫)算法總結

cocos官方文檔:節點系統事件 | Cocos Creator

游戲界面展示

一、在cocos編譯器隨便畫個頁面 展示頁面

二、連連看元素生成

2.1、準備單個方塊元素,我這里就是直接使用一張圖片,圖片大小為100x100,錨點為(0,0),這圖片命名animal,把這一張圖片設置成Prefab(預制)

(作為后面用代碼生成元素矩陣使用)

2.2、給命名animal的Prefab(預制)綁定一個ts文件,命名Animal.ts,這個類就是存放單個圖片參數了

@property(cc.SpriteFrame)
? sp1 = [];

這里就是表示不同的圖片資源,在上圖的最右邊就可以看的綁定了5張圖片進去,為了id對應,[0]位置空了

Animal.ts文件代碼如下:

//import { AnimalMgr } from "./AnimalMgr";const { ccclass, property } = cc._decorator;@ccclass
export default class Animal extends cc.Component {// 存放不同圖片,就是元素種類@property(cc.SpriteFrame)sp1 = [];// LIFE-CYCLE CALLBACKS:// onLoad () {}//存放元素種類id,用于后面匹配消除同類元素private _aid: number = 0;public get aid(): number {return this._aid;}public set aid(value: number) {this._aid = value;if (this._aid > 0 && this._aid < this.sp1.length) {this.node.getComponent(cc.Sprite).spriteFrame = this.sp1[this._aid];}}// 該元素位于矩陣第幾行(x)private _rowIndex: number = -1;public get rowIndex(): number {return this._rowIndex;}public set rowIndex(value: number) {this._rowIndex = value;}// 該元素位于矩陣第幾列(y)private _colIndex: number = -1;public get colIndex(): number {return this._colIndex;}public set colIndex(value: number) {this._colIndex = value;}// 該元素矩陣橫著總長度private _rowSum: number = -1;public get rowSum(): number {return this._rowSum;}public set rowSum(value: number) {this._rowSum = value;}// 該元素矩陣豎著總長度private _colSum: number = -1;public get colSum(): number {return this._colSum;}public set colSum(value: number) {this._colSum = value;}start() {// 點擊該元素就會觸發該方法,cocos固定點擊事件寫法this.node.on(cc.Node.EventType.TOUCH_END, (xxx) => {console.log(this.aid);// AnimalMgr.addAnimal(this);});}// update (dt) {}
}

2.3、給整個畫布綁定一個ts文件,命名Mgr.ts,后面在這個Mgr.ts文件聲明一個預制,引入上面的預置文件Animal

里面就是編寫動態生成連連看矩陣元素的邏輯

Mgr.ts文件代碼如下:

import Animal from "./Animal";
//import { AnimalMgr } from "./AnimalMgr";const { ccclass, property } = cc._decorator;@ccclass
export default class Mgr extends cc.Component {@property(cc.Prefab)T0 = null;onLoad() {}private _rows: number = 5; //矩陣的行數private _cols: number = 6; //矩陣的列數private _eleIdSum: number = 5; //可以展示圖片的種類數量start() {// console.log("start");// let _tmp = [//   [1,1,1,1,1,1,],//   [1,1,1,1,1,1,],//   [1,1,1,1,1,1,],//   [1,1,1,1,1,1,],//   [1,1,1,1,1,1,],// ]let _startx: number = -(this._cols * 100) >> 1;let _starty: number = -(this._rows * 100) >> 1;for (let index1 = 0; index1 < this._rows; index1++) {for (let index2 = 0; index2 < this._cols; index2++) {let _xxx: cc.Node = cc.instantiate(this.T0);//創建一個元素this.node.addChild(_xxx); //把這元素添加到頁面上_xxx.x = _startx;_xxx.y = _starty;_startx += 100;// 獲取這個元素組件的元素let _script: Animal = _xxx.getComponent(Animal);  //獲取這個元素的信息_script.aid = this.randomIdFn(index1, index2); //給這個元素渲染的圖片id 該方法并生成對稱id種類個數_script.rowIndex = index1; // 記錄該圖片在矩陣x軸位置_script.colIndex = index2; // 記錄該圖片在矩陣y軸位置_script.rowSum = this._rows; // 該元素矩陣橫著總長度_script.colSum = this._cols; // 該元素矩陣橫著總長度//AnimalMgr.set(index1, index2, 1); //記錄矩陣元素是否消除或者存在,1表示存在,表示不存在}_startx = -(this._cols * 100) >> 1;_starty += 100;}/* 偽節點,就是在連連看矩陣四周加多一層節點數據,標識四周一圈的節點都消除成功了,為后面的鏈接算法做處理*/// for (let index = 0; index < this._cols; index++) {//   AnimalMgr.set(-1, index, 0);// }// for (let index = 0; index < this._cols; index++) {//   AnimalMgr.set(this._rows, index, 0);// }// for (let index = 0; index < this._rows; index++) {//   AnimalMgr.set(index, -1, 0);// }// for (let index = 0; index < this._rows; index++) {//   AnimalMgr.set(index, this._cols, 0);// }}private idMap: Map<number, number> = new Map(); //收集每種元素id生成的個數,用于記錄每種元素已經生成的個數public randomIdFn(rowIndex: number, colIndex: number) {// rowIndex: 記錄元素生成到第幾行, colIndex: 記錄元素生成到第幾列//這里是末尾補偶法,前面元素隨機生成,末尾再把基數種類元素補為偶數 此方法用于保證生成的元素都為偶數對let randomId = 1 + Math.floor(Math.random() * this._eleIdSum); // 渲染的圖片id--> 1~5const eleSum = rowIndex * this._cols + colIndex; //遍歷到第幾個元素了const replenish = this._cols * this._rows - this._eleIdSum; //需要開始補充奇數位的元素開始位置if (eleSum > replenish) {//開始補充基數位的元素-->這里有5類元素,我在格子最后的五位元素補充,確保每種元素都為偶數對// let newCreateIdSum = this.idMap.get(randomId);this.idMap.forEach((value, key) => {if (value % 2 != 0) {randomId = key; //不是偶數的元素種類,補充為偶數}});}//用于記錄每種元素已經生成的個數if (this.idMap.get(randomId) && this.idMap.get(randomId) > 0) {let idSum = this.idMap.get(randomId) + 1;this.idMap.set(randomId, idSum);} else {this.idMap.set(randomId, 1); //初始化}return randomId;}// protected onDestroy(): void {// }update(dt) {}// protected lateUpdate(dt: number): void {// }
}

? ? ? ? 這里總結一下做上面所有步驟都只是為了生成一個 連連看的矩陣畫面,這里的元素生成主要邏輯是:

末尾補齊法,目的讓每一種類元素都可成為偶數,避免消除完后,最后某種元素中有單個元素在頁面上,玩家無法進行匹配,主要代碼邏輯在?public randomIdFn(rowIndex: number, colIndex: number),方法不唯一,可以用自己想法編寫

三、連連看算法邏輯編寫

3.1、在項目新建ts文件,命名AnimalMgr.ts 連連看小游戲的主要邏輯都存放在該文件

在該文件下,AnimalMgr.ts初始化代碼如下:

import Animal from "./Animal";interface VC {rowIndex: number;colIndex: number;
}class _AnimalMgr {private _animals: Array<Animal> = []; //點擊到的元素存進了,這里最大值2個元素private _paths: Map<string, number> = new Map(); //用于記錄矩陣那個元素的消除情況,1表示存在,0表示消除public addAnimal(_Animal: Animal) {if (_Animal) {//console.log(this._animals);if (this._animals.length > 0) {let _start: Animal = this._animals[0];//是否是相同元素,是就不記錄進去if (_start.colIndex == _Animal.colIndex &&_start.rowIndex == _Animal.rowIndex) {return;}}this._animals.push(_Animal);//------------if (this._animals.length == 2) {//TODO:0拐點let _isConnect: boolean = false;let _start: Animal = this._animals[0];let _stop: Animal = this._animals[1];if (_start.aid != _stop.aid) {//是否是相同元素this._animals = [];return;}if (_isConnect) {// 符合連接條件的,在視圖上銷毀這倆連接上的節點,并記錄下來這兩節點已經消除this.set(_start.rowIndex, _start.colIndex, 0);this.set(_stop.rowIndex, _stop.colIndex, 0);_start.node.destroy();_stop.node.destroy();}// console.log("_isConnect",_isConnect);this._animals = [];}}}//判斷這個節點是否存在矩陣圖形上public isPass(_r: number, _c: number) {let _key = `${_r}_${_c}`;if (this._paths.has(_key)) {return this._paths.get(_key) == 0;} else {return false;}}/* 標識矩陣每個元素的位置,并且值為1 代表存在,0代表銷毀_r: number,  //橫坐標_c: number, // 縱坐標_v: number //值為1 代表存在,0代表銷毀*/public set(_r: number, _c: number, _v: number) {let _key = `${_r}_${_c}`;this._paths.set(_key, _v);console.log(this._paths);}
}export const AnimalMgr = new _AnimalMgr();

上面AnimalMgr.ts初始化代碼主要一個目的,記錄元素在矩陣中是否存在,存在的,就在矩陣的對應位置標識為1 不存在就標識為0

3.2、然后把上面Animal.ts和Mgr.ts文件,關于引用到AnimalMgr.ts的代碼,注釋回來,就可正常隨意點擊任意兩個元素,這兩個元素就會消失在頁面上,如下圖所示:

3.3、點擊矩陣的兩個節點,是否能連接成功,符合條件就把連接成功的節點消除

下面是主要邏輯,分三步走,

(第一步)0拐點:

意思是兩個節點都是在同一條直線上,都在同一條x軸或者y軸上面,

比如A到B點,中間只是一條直線連接在同y軸上,或者C到D點也只一條直線連接,在同x軸上,

中間連接線不需要任何直角拐彎就可聯通,就表示這兩個節點0個拐點

在0拐點的兩個節點,只要中間沒有任何東西,就表示可連接成功

0拐點代碼邏輯如下,思路才是重點,代碼可以自己寫,下面代碼只做參考:

// 兩點距離0個拐角(直角)public _0c(start_: VC, stop_: VC): boolean {// 同一條橫直線上if (start_.rowIndex == stop_.rowIndex) {if (start_.colIndex < stop_.colIndex) {//向右移動let _startCol: number = start_.colIndex + 1;//判斷到下一個節點空就為true,有值就falsewhile (this.isPass(start_.rowIndex, _startCol)) {_startCol++;}return _startCol == stop_.colIndex;} else {// 向左移動let _startCol: number = start_.colIndex - 1;while (this.isPass(start_.rowIndex, _startCol)) {_startCol--;}return _startCol == stop_.colIndex;}} else if (start_.colIndex == stop_.colIndex) {// 同一條豎直線上if (start_.rowIndex < stop_.rowIndex) {//向上移動let _startRow: number = start_.rowIndex + 1;while (this.isPass(_startRow, start_.colIndex)) {_startRow++;}return _startRow == stop_.rowIndex;} else {//向下移動let _startRow: number = start_.rowIndex - 1;while (this.isPass(_startRow, start_.colIndex)) {_startRow--;}return _startRow == stop_.rowIndex;}}return;}

(第二步:假設0個拐點條件不滿足)1拐點:

意思是兩個節點坐標x和y都不相同,但是,兩個節點的連接線,只有一個直角

如下圖:

下面需要點擊A和B節點,A和B的直線距離都不能直接連接,現在需要連接只能兩條路線,每條路線只能一個直角,就只有兩條路線可走,每條路線都會有一個拐點,分別是 C和D拐點

A和B要想連接成功,路線一或者路線二,只要有一條能連接上:拐點的位置到起點和終點的直線連接都沒有阻礙物,表示A和B就可以相連

1拐點代碼邏輯如下,思路才是重點,代碼可以自己寫,下面代碼只做參考:

// 兩點距離1個拐角(直角)public _1c(start_: VC, stop_: VC): boolean {//找到兩個節點的兩個直角拐點let _p1: VC = { rowIndex: start_.rowIndex, colIndex: stop_.colIndex }; //拐角點1let _p2: VC = { rowIndex: stop_.rowIndex, colIndex: start_.colIndex }; //拐角點2let _tmp: Array<VC> = [_p1, _p2];// 判斷每個拐角點到初始點和終點之間是否有阻礙節點,有就表示行不通for (let index = 0; index < _tmp.length; index++) {const pt = _tmp[index];if (this.isPass(pt.rowIndex, pt.colIndex)) {let _isOK = true;_isOK = _isOK && this._0c(pt, start_);_isOK = _isOK && this._0c(pt, stop_);if (_isOK) {return true;}}}return false;}

(第三步:假設0個1拐點條件都不滿足)2拐點:

意思是:A到B點的連通需要滿足連接路線會出現兩個直角的

如下圖:

A點到B點要想連接成功,連接路線需要兩個拐角,

C點到D點要想連接成功,連接路線也需要兩個拐角,

兩個節點出現兩個拐角點要是想連接成功,代碼的核心思路是,在起始點,通過上下左右移動的嘗試,起始點移動到的位置,可以實現與終點連接出現一個拐點路線,就能連接成功了,就表示這兩個節點可以連接成功

2拐點代碼邏輯如下,思路才是重點,代碼可以自己寫,下面代碼只做參考:

// 兩點距離2個拐角(直角)public _2c(start_: VC, stop_: VC): boolean {// 向初始節點四面移動,判斷受否可能找到 連接到終節點的一個拐角的路線//TODO:左let _startCol: number = start_.colIndex - 1;//在初始起點向左移動,直到找到可連接到終節點的一個拐角的路線,遇到符合就終止,// 如果都不滿足,就退出向左移動的嘗試,走下面的右移動邏輯while (this.isPass(start_.rowIndex, _startCol)) {// 判斷這個節點是否存在矩陣圖形上--this.isPass(start_.rowIndex, _startCol)this.set(start_.rowIndex, _startCol, 100);//起始點左移動,標記該位置存在元素let _isOk = this._1c({ rowIndex: start_.rowIndex, colIndex: _startCol },{ rowIndex: stop_.rowIndex, colIndex: stop_.colIndex });this.set(start_.rowIndex, _startCol, 0);_startCol -= 1;if (_isOk) {return true;}}//TODO:右_startCol = start_.colIndex + 1;while (this.isPass(start_.rowIndex, _startCol)) {this.set(start_.rowIndex, _startCol, 100);let _isOk = this._1c({ rowIndex: start_.rowIndex, colIndex: _startCol },{ rowIndex: stop_.rowIndex, colIndex: stop_.colIndex });this.set(start_.rowIndex, _startCol, 0);_startCol += 1;if (_isOk) {return true;}}//TODO:上let _startRow = start_.rowIndex + 1;while (this.isPass(_startRow, start_.colIndex)) {this.set(_startRow, start_.colIndex, 100);let _isOk = this._1c({ rowIndex: _startRow, colIndex: start_.colIndex },{ rowIndex: stop_.rowIndex, colIndex: stop_.colIndex });this.set(_startRow, start_.colIndex, 0);_startRow += 1;if (_isOk) {return true;}}//TODO:下_startRow = start_.rowIndex - 1;while (this.isPass(_startRow, start_.colIndex)) {this.set(_startRow, start_.colIndex, 100);let _isOk = this._1c({ rowIndex: _startRow, colIndex: start_.colIndex },{ rowIndex: stop_.rowIndex, colIndex: stop_.colIndex });this.set(_startRow, start_.colIndex, 0);_startRow -= 1;if (_isOk) {return true;}}return false;}

AnimalMgr.ts完整代碼如下代碼如下:

import Animal from "./Animal";interface VC {rowIndex: number;colIndex: number;
}class _AnimalMgr {private _animals: Array<Animal> = []; //點擊到的元素存進了,這里最大值2個元素private _paths: Map<string, number> = new Map(); //用于記錄矩陣那個元素的消除情況,1表示存在,0表示消除// AnimalMgr.set(index1,index2,0);public addAnimal(_Animal: Animal) {if (_Animal) {//console.log(this._animals);if (this._animals.length > 0) {let _start: Animal = this._animals[0];//是否是相同元素,是就不記錄進去if (_start.colIndex == _Animal.colIndex &&_start.rowIndex == _Animal.rowIndex) {return;}}this._animals.push(_Animal);//------------if (this._animals.length == 2) {//TODO:0拐點let _isConnect: boolean = false;let _start: Animal = this._animals[0];let _stop: Animal = this._animals[1];if (_start.aid != _stop.aid) {//是否是相同元素this._animals = [];return;}_isConnect = this._0c({ rowIndex: _start.rowIndex, colIndex: _start.colIndex },{ rowIndex: _stop.rowIndex, colIndex: _stop.colIndex });//TODO:1拐點if (!_isConnect) {_isConnect = this._1c({ rowIndex: _start.rowIndex, colIndex: _start.colIndex },{ rowIndex: _stop.rowIndex, colIndex: _stop.colIndex });}//TODO:2拐點if (!_isConnect) {_isConnect = this._2c({ rowIndex: _start.rowIndex, colIndex: _start.colIndex },{ rowIndex: _stop.rowIndex, colIndex: _stop.colIndex });}if (_isConnect) {// 符合連接條件的,在視圖上銷毀這倆連接上的節點,并記錄下來這兩節點已經消除this.set(_start.rowIndex, _start.colIndex, 0);this.set(_stop.rowIndex, _stop.colIndex, 0);_start.node.destroy();_stop.node.destroy();}// console.log("_isConnect",_isConnect);this._animals = [];}}}//判斷這個節點是否存在矩陣圖形上public isPass(_r: number, _c: number) {let _key = `${_r}_${_c}`;if (this._paths.has(_key)) {return this._paths.get(_key) == 0;} else {return false;}}/* 標識矩陣每個元素的位置,并且值為1 代表存在,0代表銷毀_r: number,  //橫坐標_c: number, // 縱坐標_v: number //值為1 代表存在,0代表銷毀*/public set(_r: number, _c: number, _v: number) {let _key = `${_r}_${_c}`;this._paths.set(_key, _v);console.log(this._paths);}// 兩點距離0個拐角(直角)public _0c(start_: VC, stop_: VC): boolean {// 同一條橫直線上if (start_.rowIndex == stop_.rowIndex) {if (start_.colIndex < stop_.colIndex) {//向右移動let _startCol: number = start_.colIndex + 1;//判斷到下一個節點空就為true,有值就falsewhile (this.isPass(start_.rowIndex, _startCol)) {_startCol++;}return _startCol == stop_.colIndex;} else {// 向左移動let _startCol: number = start_.colIndex - 1;while (this.isPass(start_.rowIndex, _startCol)) {_startCol--;}return _startCol == stop_.colIndex;}} else if (start_.colIndex == stop_.colIndex) {// 同一條豎直線上if (start_.rowIndex < stop_.rowIndex) {//向上移動let _startRow: number = start_.rowIndex + 1;while (this.isPass(_startRow, start_.colIndex)) {_startRow++;}return _startRow == stop_.rowIndex;} else {//向下移動let _startRow: number = start_.rowIndex - 1;while (this.isPass(_startRow, start_.colIndex)) {_startRow--;}return _startRow == stop_.rowIndex;}}return;}// 兩點距離1個拐角(直角)public _1c(start_: VC, stop_: VC): boolean {//找到兩個節點的兩個直角拐點let _p1: VC = { rowIndex: start_.rowIndex, colIndex: stop_.colIndex }; //拐角點1let _p2: VC = { rowIndex: stop_.rowIndex, colIndex: start_.colIndex }; //拐角點2let _tmp: Array<VC> = [_p1, _p2];// 判斷每個拐角點到初始點和終點之間是否有阻礙節點,有就表示行不通for (let index = 0; index < _tmp.length; index++) {const pt = _tmp[index];if (this.isPass(pt.rowIndex, pt.colIndex)) {let _isOK = true;_isOK = _isOK && this._0c(pt, start_);_isOK = _isOK && this._0c(pt, stop_);if (_isOK) {return true;}}}return false;}// 兩點距離2個拐角(直角)public _2c(start_: VC, stop_: VC): boolean {// 向初始節點四面移動,判斷受否可能找到 連接到終節點的一個拐角的路線//TODO:左let _startCol: number = start_.colIndex - 1;//在初始起點向左移動,直到找到可連接到終節點的一個拐角的路線,遇到符合就終止,// 如果都不滿足,就退出向左移動的嘗試,走下面的右移動邏輯while (this.isPass(start_.rowIndex, _startCol)) {// 判斷這個節點是否存在矩陣圖形上--this.isPass(start_.rowIndex, _startCol)this.set(start_.rowIndex, _startCol, 100); //起始點左移動,標記該位置存在元素let _isOk = this._1c({ rowIndex: start_.rowIndex, colIndex: _startCol },{ rowIndex: stop_.rowIndex, colIndex: stop_.colIndex });this.set(start_.rowIndex, _startCol, 0);_startCol -= 1;if (_isOk) {return true;}}//TODO:右_startCol = start_.colIndex + 1;while (this.isPass(start_.rowIndex, _startCol)) {this.set(start_.rowIndex, _startCol, 100);let _isOk = this._1c({ rowIndex: start_.rowIndex, colIndex: _startCol },{ rowIndex: stop_.rowIndex, colIndex: stop_.colIndex });this.set(start_.rowIndex, _startCol, 0);_startCol += 1;if (_isOk) {return true;}}//TODO:上let _startRow = start_.rowIndex + 1;while (this.isPass(_startRow, start_.colIndex)) {this.set(_startRow, start_.colIndex, 100);let _isOk = this._1c({ rowIndex: _startRow, colIndex: start_.colIndex },{ rowIndex: stop_.rowIndex, colIndex: stop_.colIndex });this.set(_startRow, start_.colIndex, 0);_startRow += 1;if (_isOk) {return true;}}//TODO:下_startRow = start_.rowIndex - 1;while (this.isPass(_startRow, start_.colIndex)) {this.set(_startRow, start_.colIndex, 100);let _isOk = this._1c({ rowIndex: _startRow, colIndex: start_.colIndex },{ rowIndex: stop_.rowIndex, colIndex: stop_.colIndex });this.set(_startRow, start_.colIndex, 0);_startRow -= 1;if (_isOk) {return true;}}return false;}
}export const AnimalMgr = new _AnimalMgr();

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/14744.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/14744.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/14744.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

ESP32基礎應用之使用手機瀏覽器作為客戶端與ESP32作為服務器進行通信

文章目錄 1 準備2 移植2.1 softAP工程移植到simple工程中2.2 移植注意事項 3 驗證4 添加HTML4.1 瀏覽器顯示自己編譯的html4.2 在使用html發數據給ESP324.3 HTML 內容4.4 更新 html_test.html 1 準備 參考工程 Espressif\frameworks\esp-idf-v5.2.1\examples\wifi\getting_sta…

PMapper:助你在AWS中實現IAM權限快速安全評估

關于PMapper PMapper是一款功能強大的腳本工具&#xff0c;該工具本質上是一個基于Python開發的腳本/代碼庫&#xff0c;可以幫助廣大研究人員識別一個AWS賬號或AWS組織中存在安全風險的IAM配置&#xff0c;并對IAM權限執行快速評估。 PMapper可以將目標AWS帳戶中的不同IAM用戶…

Hive環境搭建

1 安裝Hive 下載文件 # wget -P /opt/ https://mirrors.huaweicloud.com/apache/hive/hive-2.3.8/apache-hive-2.3.8-bin.tar.gz 解壓縮 # tar -zxvf /opt/apache-hive-2.3.8-bin.tar.gz -C /opt/ 修改hive文件夾名字 # mv /opt/apache-hive-2.3.8-bin /opt/hive 配置環境變量 …

torch Embedding 學習筆記

文本向量化&#xff08;Text Embedding&#xff09;&#xff1a;將文本數據&#xff08;詞、句子、文檔&#xff09;表示成向量的方法。 詞向量化將詞轉為二進制或高維實數向量&#xff0c;句子和文檔向量化則將句子或文檔轉為數值向量&#xff0c;通過平均、神經網絡或主題模…

幀動畫播放出現oom異常分析及解決

問題描述 需要播放序列幀&#xff0c;幀數特別多的時候會oom 問題分析 源代碼每一幀都創建一次bitmap&#xff0c;極度消耗內存 bitmap.recycle并不會立刻回收內存&#xff0c;內存還是會很緊張 問題解決 利用inbitmap&#xff0c;每一幀復用同一片內存區域 //設置Bitmap…

【大模型部署】在C# Winform中使用文心一言ERNIE-3.5 4K 聊天模型

【大模型部署】在C# Winform中使用文心一言ERNIE-3.5 4K 聊天模型 前言 今天來寫一個簡單的ernie-c#的例子&#xff0c;主要參考了百度智能云的例子&#xff0c;然后自己改了改&#xff0c;學習了ERNIE模型的鑒權方式&#xff0c;數據流的格式和簡單的數據解析&#xff0c;實…

軟件安裝:Linux安裝Nginx

軟件安裝&#xff1a;Linux如何安裝軟件&#xff0c;程序。 源碼安裝 類似于.exe 源碼包就是一堆源代碼程序組成的。 linux tar.gz 這個就是源碼包 源碼包--------二進制包&#xff0c;源碼包里面的代碼經過編譯之后形成的包。 優點&#xff1a;1、開源&#xff0c;可以二次…

面試八股之MySQL篇1——慢查詢定位篇

&#x1f308;hello&#xff0c;你好鴨&#xff0c;我是Ethan&#xff0c;一名不斷學習的碼農&#xff0c;很高興你能來閱讀。 ??目前博客主要更新Java系列、項目案例、計算機必學四件套等。 &#x1f3c3;人生之義&#xff0c;在于追求&#xff0c;不在成敗&#xff0c;勤通…

JavaScript 數組方法總結

JavaScript 數組方法總結 創建數組訪問和修改數組&#xff08;長度 &#xff06; 元素&#xff09;添加和刪除元素數組遍歷元素查找過濾和映射歸并和縮減數組的連接數組的扁平化數組的排序數組的反轉數組的復制數組的測試數組的填充 創建數組 Array.of(...elements): 創建一個…

Singer模型與CT模型狀態轉移矩陣的求解

Singer模型與CT模型狀態轉移矩陣的求解 文章目錄 Singer模型與CT模型狀態轉移矩陣的求解前言狀態方程矩陣指數函數泰勒展開拉普拉斯變換 Singer模型CT模型 前言 回想起來&#xff0c;第一次接觸Singer模型與CT模型時的狀態轉移矩陣時&#xff0c;對求解過程一知半解。現在&…

linux 上除了shell、python腳本以外,還有什么腳本語言用得比較多?

在開始前我有一些資料&#xff0c;是我根據網友給的問題精心整理了一份「 Linux的資料從專業入門到高級教程」&#xff0c; 點個關注在評論區回復“888”之后私信回復“888”&#xff0c;全部無償共享給大家&#xff01;&#xff01;&#xff01;說到在 Linux下的編程&#xf…

柯橋成人商務英語“?cold”是“冷”,“shoulder”是“肩膀”,?cold shoulder可不是冷肩膀!

英文中有很多俚語&#xff08;idioms&#xff09;都與身體部位有關&#xff0c;非常有趣。 今天&#xff0c;英語君就為大家介紹一些和身體部位有關的俚語&#xff0c;一起來看看吧&#xff01; cold shoulder “cold shoulder”不能用字面意思理解為“冷肩膀”&#xff0c;我們…

學習毛概思想(自用)

一、單項選擇題 毛澤東思想的主要創立者是&#xff08; A &#xff09; A、毛澤東 B、劉少奇 C、周恩來 D、朱德中國共產黨內第一個提出“毛澤東思想”科學概念的是&#xff08; D  &#xff09;    A、周恩來   B、劉少奇   C、朱德…

CommonJS 和 ESM 在模塊加載和處理依賴關系的方式上的不同點理解

模塊加載&#xff1a; CommonJS&#xff1a;當執行到 require() 函數時&#xff0c;Node.js 會同步地加載模塊文件&#xff0c;即立即讀取模塊文件并執行其中的代碼&#xff0c;然后返回模塊的導出值。這就意味著&#xff0c;直到運行時我們才知道具體導入了哪些模塊&#xff0…

智慧校園學工管理系統的部署

學工體系思政服務該怎么規劃建造&#xff1f;思政作為高校育人的中心使命&#xff0c;在做到讓學生健康高興生長的一起&#xff0c;也應滿意學生生長成才的各類需求。使用技術為學生供給優質的信息化服務&#xff0c;是其間的有效途徑。大數據讓個性化教育成為可能&#xff0c;…

【題解】AB33 相差不超過k的最多數(排序 + 滑動窗口)

https://www.nowcoder.com/practice/562630ca90ac40ce89443c91060574c6?tpId308&tqId40490&ru/exam/oj 排序 滑動窗口 #include <iostream> #include <vector> #include <algorithm> using namespace std;int main() {int n, k;cin >> n &…

css中彈性布局使用方法

最近寫企業家用到許多彈性&#xff0c;感覺到彈性的重要性&#xff0c;今天給大家總結一下 彈性布局&#xff08;Flexbox&#xff09;是一種在 CSS 中用來實現靈活的布局方式&#xff0c;它能夠方便地調整容器中子元素的尺寸、順序和對齊方式。以下是一些常見的彈性布局屬性及…

【探索數據結構】線性表之順序表

&#x1f389;&#x1f389;&#x1f389;歡迎蒞臨我的博客空間&#xff0c;我是池央&#xff0c;一個對C和數據結構懷有無限熱忱的探索者。&#x1f64c; &#x1f338;&#x1f338;&#x1f338;這里是我分享C/C編程、數據結構應用的樂園? &#x1f388;&#x1f388;&…

Vue3按順序調用新增和查詢接口

Vue3按順序調用新增和查詢接口 一、前言1、代碼 一、前言 如果你想將兩個調用接口的操作封裝在不同的方法中&#xff0c;你可以考慮將這兩個方法分別定義為異步函數&#xff0c;并在需要時依次調用它們。以下是一個示例代碼&#xff1a; 1、代碼 <template><div>…