PHP code example of offdev / bandit

1. Go to this page and download the library: Download offdev/bandit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

offdev / bandit example snippets


use Offdev\Bandit\Lever;
use Offdev\Bandit\Machine;

$machine = new Machine(
    new Lever('first-lever', 123, 1),
    new Lever('second-lever', 108, 3),
    new Lever('third-lever', 115, 0),
);

use Offdev\Bandit\Strategies\EpsilonGreedy;

$strategy = new EpsilonGreedy();
$winningLever = $strategy->solve($machine);