unglud / slot-machine
Simple slot machine algorithm
v0.2
2015-05-06 12:16 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: *
- symfony/var-dumper: 3.0.*@dev
This package is not auto-updated.
Last update: 2024-10-26 19:05:11 UTC
README
Simple slot machine algorithm.
This is a simple tech demo for slot machine algorithm for PHP.
Installation
Laravel Image is distributed as a composer package. So you first have to add the package to your composer.json
file:
{
"require": {
"unglud/slot-machine": "@dev"
}
}
Usage
For start you need create Payout and test it
$slot = new SlotMachine([1000,500,300,200,150,100,60,50,40,1]); $slot->spin(); /* array:3 [ 0 => "j" 1 => "i" 2 => "d" ] */
You can test you Payout and see probabilities In result you will see something like this
dd($slot->testPayout());
array:11 [
"a|1" => 0.0476837158203
"b|3" => 0.643730163574
"c|5" => 1.78813934326
"d|7" => 3.27110290527
"e|9" => 5.21421432495
"f|11" => 6.34670257568
"g|13" => 6.28566741943
"h|15" => 8.04662704468
"i|17" => 9.37080383301
"j|47" => 4.95066642761
"total" => "45.97%"
]
Probabilities generates automatically based on Arithmetic progression, but you can set it manually on second argument:
$probs = [
'a'=>4,
'b'=>40,
'c'=>84
];
$slot = new SlotMachine([10,5,1], $probs);
More to come
Later I'll write more about theory.
License
Laravel Image is released under the MIT Licence. See the bundled LICENSE file for details.