mirror of
https://github.com/syuilo/ai.git
synced 2024-11-21 20:58:00 +00:00
complexity
This commit is contained in:
parent
ace5bf8f8f
commit
fb5db57b42
|
@ -77,10 +77,18 @@ const cellVariants = {
|
|||
|
||||
type Dir = 'left' | 'right' | 'top' | 'bottom';
|
||||
|
||||
export function genMaze(seed) {
|
||||
export function genMaze(seed, complexity?) {
|
||||
const rand = gen.create(seed);
|
||||
|
||||
const mazeSize = 11 + rand(21);
|
||||
let mazeSize;
|
||||
if (complexity) {
|
||||
if (complexity === 'easy') mazeSize = 10 + rand(12);
|
||||
if (complexity === 'hard') mazeSize = 20 + rand(15);
|
||||
if (complexity === 'veryHard') mazeSize = 35 + rand(15);
|
||||
} else {
|
||||
mazeSize = 11 + rand(21);
|
||||
}
|
||||
|
||||
const donut = rand(3) === 0;
|
||||
const donutWidth = mazeSize / 3;
|
||||
|
||||
|
|
|
@ -51,9 +51,9 @@ export default class extends Module {
|
|||
}
|
||||
|
||||
@autobind
|
||||
private async genMazeFile(seed): Promise<any> {
|
||||
private async genMazeFile(seed, size?): Promise<any> {
|
||||
this.log('Maze generating...');
|
||||
const maze = genMaze(seed);
|
||||
const maze = genMaze(seed, size);
|
||||
|
||||
this.log('Maze rendering...');
|
||||
const [temp] = await this.createTemp();
|
||||
|
@ -68,9 +68,13 @@ export default class extends Module {
|
|||
@autobind
|
||||
private async mentionHook(msg: Message) {
|
||||
if (msg.includes(['迷路'])) {
|
||||
let size = null;
|
||||
if (msg.includes(['簡単', 'かんたん', '易しい', 'やさしい', '小さい', 'ちいさい'])) size = 'easy';
|
||||
if (msg.includes(['難しい', 'むずかしい', '複雑な', '大きい', 'おおきい'])) size = 'hard';
|
||||
if (msg.includes(['死', '鬼', '地獄'])) size = 'veryHard';
|
||||
this.log('Maze requested');
|
||||
setTimeout(async () => {
|
||||
const file = await this.genMazeFile(Date.now());
|
||||
const file = await this.genMazeFile(Date.now(), size);
|
||||
this.log('Replying...');
|
||||
msg.replyWithFile(serifs.maze.foryou, file);
|
||||
}, 3000);
|
||||
|
|
Loading…
Reference in a new issue