koishi-plugin-satori-ai 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/game.d.ts +10 -0
- package/lib/gameOneTouch.d.ts +50 -0
- package/lib/gamefencing.d.ts +1 -6
- package/lib/gamegobang.d.ts +1 -7
- package/lib/gobang.cpp +3 -13
- package/lib/gobang_ai.exe +0 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +937 -129
- package/lib/mood.d.ts +2 -2
- package/lib/types.d.ts +9 -0
- package/package.json +1 -1
package/lib/game.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Session, Context } from 'koishi';
|
|
2
2
|
import { Sat } from './types';
|
|
3
3
|
import { SAT } from './index';
|
|
4
|
+
export declare enum winFlag {
|
|
5
|
+
win = 1,
|
|
6
|
+
lose = 2,
|
|
7
|
+
draw = 3,
|
|
8
|
+
pending = 4
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
11
|
* 游戏总控类,管理所有可用游戏和命令
|
|
6
12
|
*/
|
|
@@ -8,6 +14,7 @@ export declare class Game {
|
|
|
8
14
|
private GAMES;
|
|
9
15
|
private channelGames;
|
|
10
16
|
private availableGames;
|
|
17
|
+
private userUsage;
|
|
11
18
|
private context;
|
|
12
19
|
private config;
|
|
13
20
|
private sat;
|
|
@@ -16,4 +23,7 @@ export declare class Game {
|
|
|
16
23
|
startGame(session: Session, gameName: string, args: string[]): Promise<string>;
|
|
17
24
|
endGame(session: Session): Promise<string>;
|
|
18
25
|
private chat;
|
|
26
|
+
private getGameCd;
|
|
27
|
+
private getGameList;
|
|
28
|
+
private resultJudge;
|
|
19
29
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Session, Context } from 'koishi';
|
|
2
|
+
import { abstractGame, abstractGameSingleGame, gameResult } from './abstractGame';
|
|
3
|
+
import { winFlag } from './game';
|
|
4
|
+
export interface OneTouchResult extends gameResult {
|
|
5
|
+
win: winFlag;
|
|
6
|
+
message: string;
|
|
7
|
+
playerId: number;
|
|
8
|
+
}
|
|
9
|
+
declare class OneTouchSingleGame extends abstractGameSingleGame {
|
|
10
|
+
private player;
|
|
11
|
+
private ai;
|
|
12
|
+
level: number;
|
|
13
|
+
private winningFlag;
|
|
14
|
+
private turnCount;
|
|
15
|
+
private baseHP;
|
|
16
|
+
private playerLevelHP;
|
|
17
|
+
private aiLevelHp;
|
|
18
|
+
private lastScore;
|
|
19
|
+
constructor(disposeListener: () => boolean, session: Session);
|
|
20
|
+
startGame(): Promise<string>;
|
|
21
|
+
endGame: () => Promise<{
|
|
22
|
+
message: string;
|
|
23
|
+
win: winFlag;
|
|
24
|
+
gameName: string;
|
|
25
|
+
playerID: string;
|
|
26
|
+
}>;
|
|
27
|
+
private initState;
|
|
28
|
+
processInput(input: string): Promise<string>;
|
|
29
|
+
private buildTurnResult;
|
|
30
|
+
private judgeEnd;
|
|
31
|
+
private processPlayerTurn;
|
|
32
|
+
private processAiTurn;
|
|
33
|
+
private applyEffectToEnemy;
|
|
34
|
+
private applyEffectToSelf;
|
|
35
|
+
private checkCombo;
|
|
36
|
+
private buildResultMessage;
|
|
37
|
+
private aiSearchEntrance;
|
|
38
|
+
private aiSearch;
|
|
39
|
+
private generatePossibleMoves;
|
|
40
|
+
private cloneState;
|
|
41
|
+
private simulateMove;
|
|
42
|
+
private evaluateState;
|
|
43
|
+
private generateChat;
|
|
44
|
+
private instuction;
|
|
45
|
+
}
|
|
46
|
+
export declare class OneTouchGame extends abstractGame<OneTouchSingleGame> {
|
|
47
|
+
constructor();
|
|
48
|
+
startGame(session: Session, ctx: Context, args: string[]): Promise<OneTouchSingleGame>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
package/lib/gamefencing.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Session } from 'koishi';
|
|
2
2
|
import { abstractGame, abstractGameSingleGame, gameResult } from './abstractGame';
|
|
3
|
-
|
|
4
|
-
win = 1,
|
|
5
|
-
lose = 2,
|
|
6
|
-
draw = 3,
|
|
7
|
-
pending = 4
|
|
8
|
-
}
|
|
3
|
+
import { winFlag } from './game';
|
|
9
4
|
export interface fencingGameResult extends gameResult {
|
|
10
5
|
win: winFlag;
|
|
11
6
|
}
|
package/lib/gamegobang.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Session, Context } from 'koishi';
|
|
2
2
|
import { abstractGame, abstractGameSingleGame, gameResult } from './abstractGame';
|
|
3
|
-
|
|
4
|
-
win = 1,
|
|
5
|
-
lose = 2,
|
|
6
|
-
draw = 3,
|
|
7
|
-
pending = 4
|
|
8
|
-
}
|
|
3
|
+
import { winFlag } from './game';
|
|
9
4
|
export interface goBangGameResult extends gameResult {
|
|
10
5
|
win: winFlag;
|
|
11
6
|
message: string;
|
|
@@ -36,7 +31,6 @@ declare class goBangSingleGame extends abstractGameSingleGame {
|
|
|
36
31
|
private getAIMove;
|
|
37
32
|
private checkWin;
|
|
38
33
|
private checkDirection;
|
|
39
|
-
private place;
|
|
40
34
|
private printBoard;
|
|
41
35
|
private generateChat;
|
|
42
36
|
}
|
package/lib/gobang.cpp
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// g++ -O3 -
|
|
1
|
+
// g++ -O3 -static -std=c++11 gobang.cpp -o gobang_ai.exe
|
|
2
2
|
#define _CRT_SECURE_NO_WARNINGS
|
|
3
3
|
#include <stdio.h>
|
|
4
4
|
#include <stdlib.h>
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
#include <string>
|
|
7
7
|
#include <iostream>
|
|
8
8
|
#include <sstream>
|
|
9
|
-
#include <omp.h>
|
|
10
9
|
#define BOARD_SIZE 14 // 棋盘大小
|
|
11
10
|
#define EMPTY 0 // 空位
|
|
12
11
|
#define BLACK 1 // 黑棋
|
|
@@ -540,7 +539,8 @@ inline int singleScore(coordinate p, int player, const Game &game)
|
|
|
540
539
|
score += chesstype.win5 << 20;
|
|
541
540
|
score += ((chesstype.conti4 << 9) + (chesstype.alive3 << 8) + (chesstype.conti3 << 7) + (chesstype.alive4 << 10) +
|
|
542
541
|
(chesstype.jump3 << 6) + (chesstype.alive2 << 5) + (chesstype.jump2 << 3) + chesstype.conti2 + chesstype.alive1);
|
|
543
|
-
if (chesstype.alive3 > 1 || (chesstype.conti4 && chesstype.alive3) || chesstype.alive4 || chesstype.conti4 > 1
|
|
542
|
+
if (chesstype.alive3 > 1 || (chesstype.conti4 && chesstype.alive3) || chesstype.alive4 || chesstype.conti4 > 1 ||
|
|
543
|
+
(chesstype.jump3 && chesstype.alive3) || chesstype.jump3 > 1 || (chesstype.conti4 && chesstype.jump3)) // 必胜?
|
|
544
544
|
score += (1 << 12);
|
|
545
545
|
return score;
|
|
546
546
|
}
|
|
@@ -561,8 +561,6 @@ int wholeScore(int player, const Game &game)
|
|
|
561
561
|
length++;
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
// 计算每个点的分数
|
|
565
|
-
#pragma omp parallel for reduction(+:Score) schedule(dynamic, 4)
|
|
566
564
|
for (int i = 0; i < length; i++)
|
|
567
565
|
{
|
|
568
566
|
if (temps[i].score == player)
|
|
@@ -620,14 +618,6 @@ coordinate alphaBeta(int depth, int alpha, int beta, int player, coordinate comm
|
|
|
620
618
|
temp.score = wholeScore(player, game);
|
|
621
619
|
return temp;
|
|
622
620
|
}
|
|
623
|
-
// if (singleScore(temp, player, game) >= (1 << 20)) // 如果当前落子win5
|
|
624
|
-
// {
|
|
625
|
-
// if (player == game.myFlag)
|
|
626
|
-
// temp.score = 6000000 + temp.x * 100 + temp.y;
|
|
627
|
-
// else
|
|
628
|
-
// temp.score = 2000000 + temp.x * 100 + temp.y;
|
|
629
|
-
// return temp;
|
|
630
|
-
// }
|
|
631
621
|
coordinate steps[BOARD_SIZE * BOARD_SIZE];
|
|
632
622
|
int length = inspireSearch(steps, player, game); // 搜索可落子点
|
|
633
623
|
if (length > 2)
|
|
Binary file
|
package/lib/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Context, Session } from 'koishi';
|
|
|
2
2
|
import { Sat, User } from './types';
|
|
3
3
|
import Puppeteer from 'koishi-plugin-puppeteer';
|
|
4
4
|
export declare let puppeteer: Puppeteer | null;
|
|
5
|
+
export declare function refreshPuppeteer(ctx: Context): void;
|
|
5
6
|
export declare class SAT extends Sat {
|
|
6
7
|
config: Sat.Config;
|
|
7
8
|
private apiClient;
|
|
@@ -10,6 +11,7 @@ export declare class SAT extends Sat {
|
|
|
10
11
|
private ChannelParallelCount;
|
|
11
12
|
private onlineUsers;
|
|
12
13
|
private moodManager;
|
|
14
|
+
private usersToWarn;
|
|
13
15
|
private game;
|
|
14
16
|
constructor(ctx: Context, config: Sat.Config);
|
|
15
17
|
private getAPIConfig;
|
|
@@ -39,6 +41,8 @@ export declare class SAT extends Sat {
|
|
|
39
41
|
private buildSystemPrompt;
|
|
40
42
|
private getThinkingPrompt;
|
|
41
43
|
private formatResponse;
|
|
44
|
+
private addUserToWarnList;
|
|
45
|
+
getWarningList(session: Session): Promise<void>;
|
|
42
46
|
private clearSession;
|
|
43
47
|
private addCommonSense;
|
|
44
48
|
private handleUserLevel;
|