Skip to content

Commit

Permalink
Add statistic tests and graph
Browse files Browse the repository at this point in the history
  • Loading branch information
hxtree committed Mar 8, 2021
1 parent 9d4217a commit de5de30
Show file tree
Hide file tree
Showing 6 changed files with 100,042 additions and 24 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

A library for simulating luck based dice rolls from dice notations written in PHP.

This graph shows 10,000 consecutive `10d10` rolls with fluctuations in luck that impact outcome.
<p align="center"><img src="https://raw.githubusercontent.com/ouxsoft/LuckByDice/main/docs/statistics.png" alt="statistics"/></p>

## Installation


Expand Down
8 changes: 7 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ a luck.
// our luck effects our next roll
echo $turn->roll();
This graph shows 10,000 consecutive `10d10` rolls with fluctuations in luck that impact outcome.
|graph|

Installation
------------
Expand Down Expand Up @@ -68,4 +70,8 @@ Indices and tables

.. |logo| image:: https://raw.githubusercontent.com/ouxsoft/LuckByDice/main/docs/logo.png
:width: 400
:alt: LuckByDice
:alt: LuckByDice

.. |graph| image:: https://raw.githubusercontent.com/ouxsoft/LuckByDice/main/docs/statistics.png
:width: 400
:alt: Statistics
Binary file added docs/statistics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 0 additions & 23 deletions tests/App.php

This file was deleted.

31 changes: 31 additions & 0 deletions tests/src/Statistics/App.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

require '../../../vendor/autoload.php';

use Ouxsoft\LuckByDice\Factory\TurnFactory;

$turn = TurnFactory::getInstance();

$turn->setNotation('10d10');

$fp = fopen('data.csv', 'w');

// add column headings
$fields = [
'Roll',
'Outcome',
'Luck'
];
fputcsv($fp, $fields);

// add rows
for($i = 1; $i <= 100000; $i++){
$fields = [
$i,
$turn->roll(),
$turn->getLuck()
];
fputcsv($fp, $fields);
}

fclose($fp);
Loading

0 comments on commit de5de30

Please sign in to comment.