aigamedev/resistance

语言: Python

git: https://github.com/aigamedev/resistance

THE RESISTANCE板和纸牌游戏的框架,带有各种AI机器人。
Framework for THE RESISTANCE board & card game, with various AI bots.
README.md (中文)

抵抗AI

THE RESISTANCE板卡和纸牌游戏的Python框架,以及为游戏/ AI大会2012年比赛提交的各种AI机器人。

|构建状态|


建造机器人

要创建自己的bot,最好的起点如下:

  1. 接口 - 您必须实现的API位于player.py中,特别是名为Bot的类。
  2. 示例 - 要查找要学习的示例,请参阅bots / beginners.py以了解某些默认行为。

基本上,您必须为机器人在游戏中必须做出的每个关键决策实现功能(例如选择,投票或破坏),然后选择覆盖回调函数以获取其他信息(例如onMissionComplete)。

每个机器人还有一个self.game数据结构,存储有关游戏本身的信息。这引用的类是game.py顶部的State - 您应该查询详细信息。

举办比赛

如果您想快速测试代码并评估性能,您可以进行数千场游戏的长时间比赛。这是通过存储库根目录中的competition.py脚本完成的。

与相关路径的机器人一起开展竞赛如下::

> python competition.py 1000 bots/beginners.py

假设路径设置,从python模块运行竞争::

> PYTHONPATH=bots python competition.py 1000 beginners.Hippie beginners.Paranoid

这些独立竞赛在没有依赖性的情况下运行,并且还与PyPy_一起运行以获得额外的性能。

.. image :: docs / competition.png

该脚本输出排名表,其中阻力和间谍的分数分别作为胜利的百分比,然后低于它们的组合。两个投票列跟踪正确的向上投票和正确的投票,这取决于它是间谍还是抵抗。投票专栏显示其他人支持包括此玩家在内的团队的频率。所选列显示了选择玩家的频率,选择跟踪选择有或没有间谍的队伍(取决于角色)。

IRC上的互动游戏

如果您想与机器人进行交互以获得乐趣或测试,您可以通过Internet Relay Chat和两个名为client.py(启动机器人)和master.py(协调游戏)的脚本来实现。

运行基于交互式文本的游戏需要一些依赖性,特别是对于网络和IRC连接::

> pip install twisted

然后你可以通过在命令行中指定它们来运行你的机器人,直到你按下CTRL + C ::

> python client.py bots/beginners.py --server=localhost
CONNECTED Hippie.
CONNECTED Neighbor.
^C
DISCONNECT Neighbor.
DISCONNECT Hippie.

要通过IRC与他们互动,请连接您自己的IRC客户端并加入#resistance频道。您应该看到那里的用户中列出的机器人。

如果没有主/主持人,通常在用户列表中也可以看到另一个名为aigamedev的机器人,你需要按如下方式启动它::

> python master.py --server=localhost

在此之后,您可以通过在#resistance频道中键入消息在IRC中启动游戏::

[alexjc]    PLAY alexjc, Hippie, Paranoid, Deceiver, Random.
[aigamedev] PLAYING alexjc Hippie Paranoid Deceiver Random!

然后,您可以按照IRC客户端中的说明自行玩游戏。

.. |建立状态| image :: https://travis-ci.org/aigamedev/resistance.png?branch=master    :target:https://travis-ci.org/aigamedev/resistance

.. _PyPy:http://pypy.org/

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

THE RESISTANCE AI

Python framework for THE RESISTANCE board & card game, along with various AI bots submitted for the 2012 competition at the Game/AI Conference.

|Build Status|


Building Bots

To create your own bot, the best places to start are the following:

  1. Interface — The API you must implement is located in player.py, specifically a class called Bot.
  2. Examples — To find samples to learn from, see bots/beginners.py for some default behaviors.

Basically, you must implement functions for each of the key decisions the bot has to make in the game (e.g. select, vote or sabotage), and then have the option of overriding callback functions to get additional information (e.g. onMissionComplete).

Each bot also has a self.game data-structure that stores information about the game itself. The class this refers to is State at the top of game.py — which you should consult for details.

Running Competitions

If you want to quickly stress test the code and evaluate performance, you can run long competitions of thousands of games. This is done via the competition.py script in the root of the repository.

Launch a competition with bots from a relative path as follows::

> python competition.py 1000 bots/beginners.py

Run a competition from a python module, assuming the path is set::

> PYTHONPATH=bots python competition.py 1000 beginners.Hippie beginners.Paranoid

These standalone competitions run without dependencies, and also run with PyPy_ for additional performance.

.. image:: docs/competition.png

The script outputs ranking tables with scores for resistance and spies separately as percentage of wins, then below they are combined. The two vote columns track correct up-votes and correct down-votes, depending on whether it's spy or or resistance. The voted column shows how often others supported a team including this player. The selected column shown how often the player was selected, and selection tracks the picking of teams with or without spies (depending on role).

Interactive Play on IRC

If you want to interact with your bot for fun or testing, you can do this via Internet Relay Chat and the two scripts called client.py (to launch your bot) and master.py (to coordinate games).

Running interactive text-based games requires some dependencies, in particular for networking and IRC connection::

> pip install twisted

Then you can run your bots by specifying them on the command-line, until you press CTRL+C::

> python client.py bots/beginners.py --server=localhost
CONNECTED Hippie.
CONNECTED Neighbor.
^C
DISCONNECT Neighbor.
DISCONNECT Hippie.

To interact with them via IRC, connect your own IRC client and join the #resistance channel there. You should see the bots listed in the users there.

If there's no master/moderator, another bot usually called aigamedev also visible in the user list, you'll need to launch it as follows::

> python master.py --server=localhost

After this, you can launch a game within IRC by typing a message into the #resistance channel::

[alexjc]    PLAY alexjc, Hippie, Paranoid, Deceiver, Random.
[aigamedev] PLAYING alexjc Hippie Paranoid Deceiver Random!

Then you can follow the instructions within your IRC client to play the game itself.

.. |Build Status| image:: https://travis-ci.org/aigamedev/resistance.png?branch=master
:target: https://travis-ci.org/aigamedev/resistance

.. _PyPy: http://pypy.org/