机器人游戏的游戏引擎

rgkit的Python项目详细描述


Build StatusDownloads

作为包安装

pip

安装工具包的最简单方法是 pip。从终点站, 运行:

pip install rgkit

或者如果您想要开发版本:

pip install git+https://github.com/RobotGame/rgkit.git

注意:这将在系统范围内安装rgkit。建议使用virtualenv来管理开发环境。

virtualenv

使用virtualenv安装需要以下步骤:

mkdir my_robot
cd my_robot
virtualenv env
source env/bin/activate
pip install rgkit

setup.py

也可以直接从源文件夹手动安装。做一个 git存储库的本地副本或下载源文件。那么, 使用终端,从 源代码:

python setup.py install

注意:这将在系统范围内安装rgkit。建议使用virtualenv来管理开发环境。

运行游戏

安装包后,脚本可以通过命令执行 line(如果您使用的是virtualenv,请记住激活环境)。 提供了两个入口点:rgrunrgmap。这个 run的一般用法是:

usage: rgrun [-h] [-m MAP] [-c COUNT] [-A] [-q] [-H | -T | -C]
             [--game-seed GAME_SEED]
             [--match-seeds [MATCH_SEEDS [MATCH_SEEDS ...]]] [-r]
             player1 player2

Robot game execution script.

positional arguments:
  player1               File containing first robot class definition.
  player2               File containing second robot class definition.

optional arguments:
  -h, --help            show this help message and exit
  -m MAP, --map MAP     User-specified map file.
  -c COUNT, --count COUNT
                        Game count, default: 1, multithreading if >1
  -A, --animate         Enable animations in rendering.
  -q, --quiet           Quiet execution.
                        -q : suppresses bot stdout
                        -qq: suppresses bot stdout and stderr
                        -qqq: supresses all rgkit and bot output
  -H, --headless        Disable rendering game output.
  -T, --play-in-thread  Separate GUI thread from robot move calculations.
  -C, --curses          Display game in command line using curses.
  --game-seed GAME_SEED
                        Appended with game countfor per-match seeds.
  --match-seeds [MATCH_SEEDS [MATCH_SEEDS ...]]
                        Used for random seed of the first matches in order.
  -r, --random          Bots spawn randomly instead of symmetrically.

因此,从包含您的_robot.py的目录中,您可以运行一个游戏 针对默认robot并使用以下命令抑制gui输出 命令:

rgrun -H your_robot.py defaultrobots.py

利用源代码开发

rgkit打包为一个模块,但是可以只签出 存储库和导入/运行源脚本。

./rgkit
|--- rgkit
|    |--- __init__.py
|    |--- game.py
|    |--- run.py
|    |--- ...
|    |--- your_robot.py
|--- setup.py
...
/path/your_other_robot.py

运行游戏

要以这种方式配置源代码运行游戏,请使用终端 并从内部rgkit文件夹(即 与run.py目录相同:

python run.py your_robot.py /path/your_other_robot.py

为自己的机器人编码

一旦安装,您只需要rg模块来开发 拥有机器人。包可以像任何其他模块一样导入:

import rg

class Robot:
    def act(self):
        return ['guard']

其他工具

以下是一些由其他玩家制作的优秀工具!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java通过两个整数数组对正整数和负整数进行排序   java无参数和默认构造函数混淆   java加载文件MD5的最快方法是什么?   java如何在变量声明中使用带“e”的float   java将项目导入到STS iMac   java在使用图像时旋转图像   java Break语句不起作用   java提供了错误类型Spring的id   java如何为多个变量设置相同的函数属性?   JavaMaven:如何添加编译阶段后生成的资源   java HashMap已损坏/性能问题   java Hibernate SQL中间表b/w父表和子表(不同类型)   java PDFbox找不到字体:/Helv   Java:向自实现的双链接列表添加排序函数   为使用Java BouncyCastle生成的X509Certificate提供密钥使用的安全性   java Hibernate在读写方面的性能   C#相当于Java的DataOutputStream?