Giter VIP home page Giter VIP logo

nonebot_plugin_maze's Introduction

NoneBotPluginLogo

NoneBotPluginText

Nonebot_Plugin_Maze

✨ 基于OneBot适配器的NoneBot2交互式解迷宫插件 ✨

功能

  • 可指定大小与算法生成迷宫
  • 发送方向与步数解迷宫
  • 游戏过程中可随时退出

安装

  • 使用 nb-cli
nb plugin install nonebot_plugin_maze
  • 使用 pip
pip install nonebot_plugin_maze

获取插件帮助

如何使用

.env 配置项

min_maze_rows: int = 13            # 迷宫最小行数
max_maze_rows: int = 35            # 迷宫最大行数
min_maze_cols: int = 13            # 迷宫最小列数
max_maze_cols: int = 35            # 迷宫最大列数
default_maze_rows: int = 18        # 迷宫默认生成行数
default_maze_cols: int = 27        # 迷宫默认生成列数
maze_movement_key: str = "ULDR"    # 迷宫移动方向键

各配置项的含义与默认值如上。

  • 对于以上配置项,规定需同时满足min_maze_rows <= default_maze_rows <= max_maze_rows以及min_maze_cols <= default_maze_cols <= max_maze_cols

  • 因此,在修改一些配置项时可能强制需要连着某些其他的配置项一起修改。

  • 同时,建议不要把最小行数/列数设置为小于10的值,以免引发未知错误

    • 也建议不要把最大行数/列数设置过大,例如50以上,第一是因为资源占用问题,第二是因为生成个那么大的迷宫有谁愿意玩啊喂
  • 可遵循上左下右的格式修改移动方向键,例如WASD,规定方向键只能为字母

开始游戏

使用以下命令触发,需加上命令前缀!

maze [-r --rows <ROWS>] [-c --cols <COLUMNS>] [-m --method <ALGORITHM>]
  • 可使用-r规定迷宫的行数,-c规定迷宫的列数

    • 以上两项参数的范围和默认值参考.env文件中的相关配置项。
  • 可使用-m规定迷宫的生成算法,目前支持DFSPrimKruskal三种算法,默认值为Kruskal,检测此参数时对大小写不敏感。

如何进行游戏

在用户发送指令获取到初始迷宫后,我们终于可以愉快地开始游戏了!

用户需要持续发送操作序列以在迷宫中移动,直到解开迷宫。

要知道操作序列是什么,首先要定义操作

注:以下定义使用默认参数maze_movement_key = "ULDR"

  • 我们定义一个操作的格式为方向+步数,用正则表达就是[UDLR]\d*,用阳间方法表达的话就是U(up)|D(down)|L(left)|R(right) + steps步数可以留空以表示一步。

  • 例如RD3L1就是几个合法的操作,分别表示右移一步,下移三步,左移一步。

    • 为避免频繁数格子的问题,我们定义一步为沿该方向的路径一直走,直到遇见死路或走到岔路口。

有了操作是什么,我们定义操作序列为n(n≥1)个操作组合而成的字符串。

游戏中觉得太耗时间?迷宫太难解不出来?不想玩了?

  • 可以在游戏过程中随时发送结束或者quit以结束游戏并获取参考解法。

演示

只用文字描述往往十分吃力,废话不多说,上Demo:

nonebot_plugin_maze's People

Contributors

etherleaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

nonebotjs

nonebot_plugin_maze's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.