lucidtaz/minimax

用于游戏决策的MiniMax引擎

0.2.0 2017-07-26 19:44 UTC

This package is auto-updated.

Last update: 2024-09-25 02:14:50 UTC


README

Build Status Scrutinizer Code Quality Code Coverage

PHP中的MiniMax引擎

此库提供了一种简单的方法,将MiniMax游戏决策算法集成到您的游戏中,通过简单的接口将算法与游戏逻辑分离。

使用方法

要使用此库,首先确保您在 lucidtaz\minimax\game 中实现了每个接口。

然后,简单地构建一个 lucidtaz\minimax\engine\Engine 的实例,给它一个 Player 作为操作者,并在玩家轮到时调用 decide() 方法。这将导致引擎移动后的 GameState 实例。

代码示例

class MyPlayer implements \lucidtaz\minimax\game\Player
{
    ...
}

class MyGameState implements \lucidtaz\minimax\game\GameState
{
    ...
}

$player = new MyPlayer(...);
$engine = new \lucidtaz\minimax\engine\Engine($player);

$gameState = new MyGameState(...);

$newGameState = $engine->decide($gameState);

请参阅 tests/tictactoe 目录或 tests/ 中其他示例游戏实现以获取示例。