Download the PHP package ipapikas/dice without Composer

On this page you can find all versions of the php package ipapikas/dice. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dice

Dice

Dice allows you to pick an option from a given pool with a given set of probabilities.

StyleCI Latest Stable Version Total Downloads License

Introduction

Dice is a basic library that offers a random handler for simulating the throw of a Dice. In other words, it allows you to choose an option from a given set of options with specified probabilities.

Dice provides a set of Distributions and Randomizers to allow you to select your own. You can select Distributions that have equal probabilities (Dice, Coin etc.) or build your own Distributions that might not have the same probabilities, depending on the usage.

Dice is still in beta version and we are making extended tests and use cases to validate its use and create a stable version.

Installation

You can install Dice simply by adding the files into your project or using the composer.

Through the composer

Add the following line to your composer.json file:

Roller

Dice includes a main Roller that receives a Distribution and a Randomizer and selects the next value of the given Distribution.

Example:

How It Works

Roller has the main logic of the library here. Roller is the main handler that is responsible for taking the next value of the distribution and making sure that there is enough logic to be able to choose among a set of values.

Roller's work is to take all value possibilities and expand them into a world where there are 100 (or 1000 or more) pebbles. Based on the probability distribution, the Roller selects a specific number of pebbles and colors them with the value of the Distribution. Based on the probability, it selects the right amount of pebbles in order to allow the the Distribution to be biased or unbiased. After the expansion is over, it uses the Randomizer to select a pebble from 1 to 100 (or 1000 or more). Since the pebbles are a lot more than the values in the Distribution, we can make sure that it can work without making any biased decisions or leaving anything out.

Pebbles

The number of pebbles is determined based on the amount of precision is needed for the given probabilities.

If the probabilities are just 50% each, 10 pebbles are enough to choose a number between 1 and 10 and determine which pebbles are which value.

If the probabilities are in as low as 1.5%, the amount of pebbles will be 1000, to allow 1.5% to be seen a 15 pebbles at least.

Keep in mind

Based on the description above, the amount of pebbles is determined by the amount of precision.

It is essential to build your Distributions to use ProbabilityValidator to make sure that your probabilities sum up to 1. Otherwise, Roller will not be able to select properly your values and it will leave some cases (pebbles) out.

For example, if you have the following probabilities:

The above sum up to 105% (or 1.05). The amount of pebbles will be set to 100, leaving out 5 pebbles for the last probability, which will be capped to the following:

Or there are cases where a value might be removed from the pebble pool, because it was completely above 1. Example:

Distributions

You can easily create your own distribution that will match your needs. All you have to do is to setup your validators, if any.

In your code, you can set your own items as dynamic values based on your own logic.

Example:

If you are developing a game, you can build the above Distribution to decide what the weather be like every single day.

Or, you can set the Distribution to be biased and be more rainy than usual (66% chance of rain and 11% of any other weather):


All versions of dice with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ipapikas/dice contains the following files

Loading the files please wait ....