prokki / warlight2-bot-template
Warlight AI Challenge 2 的机器人模板
0.4.0
2017-03-14 16:15 UTC
Requires
- php: >=5.4
- prokki/theaigames-bot-engine: ^0.1.0
Requires (Dev)
- phpunit/phpunit: ^5.0
README
这是一个为 Warlight AI Challenge 2(http://theaigames.com/competitions/warlight-ai-challenge-2)提供的 PHP 机器人模板。
注意:项目处于测试阶段。请随时报告您遇到的问题。
安装
Composer
创建一个新项目,并通过以下命令使用 Composer 安装模板:
composer require prokki/warlight2-bot-template
使用方法
创建您的机器人
通过继承 Prokki\Warlight2BotTemplate\AIBot 类来创建您自己的机器人。为了确保机器人响应正确,该类必须实现 Prokki\Warlight2BotTemplate\Bot\AI 接口。
以下方法必须重写
use Prokki\TheaigamesBotEngine\Bot; class AIBot implements Bot, AI { /** * Returns the pick move of the region to pick. * * These moves are going to build the response to the request `pick_starting_region` - see {@see \Prokki\Warlight2BotTemplate\Command\PickStartingRegionCommand}. * * @param integer[] $region_ids * * @return PickMove|null */ public function getPickMove($region_ids) { // put your code here } /** * Returns all place moves. * * These moves are going to build the response to the request `go place_armies` - see {@see \Prokki\Warlight2BotTemplate\Command\GoPlaceArmiesCommand}. * * @return PlaceMove[] */ public function getPlaceMoves(); { // put your code here } /** * Returns all attack and transfer moves. * * These moves are going to build the response to the request `go attack/transfer` - see {@see \Prokki\Warlight2BotTemplate\Command\GoAttackTransferCommand}. * * @return TransferMove[]|AttackMove[] */ public function getAttackTransferMoves(); { // put your code here } }
自定义游戏类
为了为您的无敌机器人添加启发式数据、静态数据或其他自定义数据,您可以为管理附加信息添加自定义类。但除了添加额外的类之外,机器人引擎提供了一个更好的方法来为您的机器人添加自定义信息:您可以通过扩展与游戏相关的基类来添加自己的属性和方法。
\Prokki\TheaigamesBotEngine\Game\EnvironmentFactory
实现了工厂模式,通过一个类创建所有与游戏相关的对象。覆盖此类可以赋予您使用具有自定义属性的自定义类的能力。
请参阅示例 Prokki\Warlight2BotTemplate\Example\StupidRandomBot 以获取更多信息。