andreluizmachado/tictactoe-library

There is no license information available for the latest version (dev-master) of this package.

The tic tac toe engine

dev-master 2018-03-19 14:33 UTC

This package is not auto-updated.

Last update: 2022-11-30 03:02:29 UTC


README

The engine of the tic tac tog game

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Docker >= v17.05
  • php >= 7.2

Installing

composer require andreluizmachado/tictactoe-library

Usage

To get the next move by bot:

    use AndreLuizMachado\TicTacToe\Engine\Bot;
    ...
    $bot = new Bot(
        [ //previous plays of current game
            [
                'column' => 3,
                'line' => 3,
            ],
        ]
    );

    $nextPlay = $bot->getNextPlay();
    var_dump($nextPlay);
    ....

To check the board

    use AndreLuizMachado\TicTacToe\Engine\Board;
    use AndreLuizMachado\TicTacToe\Engine\Player;
    ...
        $player2 = new Player(
            [
                [
                    'column' => 3,
                    'line' => 2,
                ],
                [
                    'column' => 3,
                    'line' => 3,
                ],
            ]
        );

        $player1 = new Player(
            [
            [
                    'column' => 1,
                    'line' => 1,
                ],
                [
                    'column' => 1,
                    'line' => 2,
                ],
                [
                    'column' => 1,
                    'line' => 3,
                ],
            ]
        );

        $board = new Board($player1, $player2);
        $game = $board->checkGame();
        var_dump($game);
    ....

Running the tests

./run-install.sh 
./run-testing.sh

Authors

André Luiz Machado