定制 robertasproniu/tic-tac-toe-agent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

robertasproniu/tic-tac-toe-agent

Composer 安装命令:

composer require robertasproniu/tic-tac-toe-agent

包简介

A Tic Tac Toe Game

README 文档

README

A PHP Tic Tac Toe Game package with AI included

for installing just type:

Installing

You can install the library via Composer, or by downloading it directly on GitHub.

Composer

Set up a Composer project, then run the following command:

php composer.phar require robertasproniu/tic-tac-toe-agent

Basic usage

To create a game instance, use:

<?php
require_once __DIR__ . '/vendor/autoload.php'; // Composer
// OR
require_once __DIR__ . '/src/TicTacToe.php'; // ZIP download

use \TicTacToeAgent\TicTacToe;
use \TicTacToeAgent\Board;

$game = new TicTacToe(new Board()); // Create a new game

Now, you have created a new game with a empty board.

You can see the board by using the getBoard() method:

print_r( $game->getBoard() );

Also you can set players symbols by accessing setPlayers() method:

$game->setPlayers(['X', 'O']);

For getting recommended move for a player you need to pass board and player symbol by using makeMove(array $board, $player ) method:

$move = $game->makeMove(array_fill(0, 9, null), 'X'); // board can be multidimensional array too

print_r($move); // [2,0,'X'] if available position else [];

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固