Xyaneon.Games.Dice 2.0.2

dotnet add package Xyaneon.Games.Dice --version 2.0.2                
NuGet\Install-Package Xyaneon.Games.Dice -Version 2.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xyaneon.Games.Dice" Version="2.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xyaneon.Games.Dice --version 2.0.2                
#r "nuget: Xyaneon.Games.Dice, 2.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xyaneon.Games.Dice as a Cake Addin
#addin nuget:?package=Xyaneon.Games.Dice&version=2.0.2

// Install Xyaneon.Games.Dice as a Cake Tool
#tool nuget:?package=Xyaneon.Games.Dice&version=2.0.2                


License NuGet main Coverage Status semantic-release: conventionalcommits

Package Icon

A .NET Standard 2.0 library for dice, including standard and custom dice.



To use this library, you must first install the NuGet package for it, then add the following using statement at the top of each C# source file where you plan on using it:

using Xyaneon.Games.Dice;

Rolling standard dice

Single rolls

This library provides several built-in classes representing standard dice, including:

  • D4
  • D6
  • D8
  • D10
  • D12
  • D20

These each inherit from Dice<int>. You can just call them with an empty constructor to start using them right away. An optional seed integer can also be passed into a die's constructor if you want a repeatable pseudorandom sequence of rolled values.

After creation, you can simply call the Roll method to get a random result:

var die = new D6();

int rollResult = die.Roll(); // Can be 1, 2, 3, 4, 5 or 6.
Multiple rolls

To avoid having to call Roll multiple times, you can also supply an integer indicating how many rolls you want, then get the results as an IEnumerable<int>:

var die = new D20();

// Sample returned sequence: [6, 18, 4, 20, 1]
IEnumerable<int> rollResult = die.Roll(5);

Flipping coins

This library also provides a Coin class, which is considered to be a two-sided die. Flips are returned as CoinFlipResult enum values:

var coin = new Coin();

// Could return CoinFlipResult.Heads or CoinFlipResult.Tails.
CoinFlipResult flipResult = coin.Flip();

Custom dice

You are not restricted to standard number dice. The Die<TFace> base class is generic and can be instantiated using a custom collection of your choice representing the die's faces.

var colorDie = new Die<Color>(new Color[] {

Color rollResult = die.Roll();

Symbols conversion

A static Symbols class is also provided with constants for D6 faces, and a couple conversion methods:

  • Symbols.GetD6ValueForSymbol(char symbol)
  • Symbols.GetSymbolForD6Value(int value)

You can use these to get from a ⚃ character to a 4 or vice versa, for example.


This library is free and open-source software provided under the MIT license. Please see the LICENSE.txt file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Xyaneon.Games.Dice:

Package Downloads

A .NET Standard metapackage for card and board game functionality and components, such as dice and cards.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.2 261 2/11/2023
2.0.1 249 1/24/2023
2.0.0 258 1/24/2023
1.0.0 276 1/22/2023
0.1.0 793 4/10/2020