class_randomnumbergenerator.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the RandomNumberGenerator.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_RandomNumberGenerator:
  5. RandomNumberGenerator
  6. =====================
  7. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. A class for generating pseudo-random numbers.
  12. Properties
  13. ----------
  14. +-----------------------+--------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`seed<class_RandomNumberGenerator_property_seed>` |
  16. +-----------------------+--------------------------------------------------------+
  17. Methods
  18. -------
  19. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`float<class_float>` | :ref:`randf<class_RandomNumberGenerator_method_randf>` **(** **)** |
  21. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`float<class_float>` | :ref:`randf_range<class_RandomNumberGenerator_method_randf_range>` **(** :ref:`float<class_float>` from, :ref:`float<class_float>` to **)** |
  23. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`float<class_float>` | :ref:`randfn<class_RandomNumberGenerator_method_randfn>` **(** :ref:`float<class_float>` mean=0.0, :ref:`float<class_float>` deviation=1.0 **)** |
  25. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`randi<class_RandomNumberGenerator_method_randi>` **(** **)** |
  27. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`int<class_int>` | :ref:`randi_range<class_RandomNumberGenerator_method_randi_range>` **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)** |
  29. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`randomize<class_RandomNumberGenerator_method_randomize>` **(** **)** |
  31. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  32. Description
  33. -----------
  34. RandomNumberGenerator is a class for generating pseudo-random numbers. It currently uses PCG32. The underlying algorithm is an implementation detail. As a result, it should not be depended upon for reproducible random streams across Godot versions.
  35. Property Descriptions
  36. ---------------------
  37. .. _class_RandomNumberGenerator_property_seed:
  38. - :ref:`int<class_int>` **seed**
  39. +----------+-----------------+
  40. | *Setter* | set_seed(value) |
  41. +----------+-----------------+
  42. | *Getter* | get_seed() |
  43. +----------+-----------------+
  44. The seed used by the random number generator. A given seed will give a reproducible sequence of pseudo-random numbers.
  45. **Note:** The RNG does not have an avalanche effect, and can output similar random streams given similar seeds. Consider using a hash function to improve your seed quality if they're sourced externally.
  46. Method Descriptions
  47. -------------------
  48. .. _class_RandomNumberGenerator_method_randf:
  49. - :ref:`float<class_float>` **randf** **(** **)**
  50. Generates pseudo-random float between '0.0' and '1.0', inclusive.
  51. .. _class_RandomNumberGenerator_method_randf_range:
  52. - :ref:`float<class_float>` **randf_range** **(** :ref:`float<class_float>` from, :ref:`float<class_float>` to **)**
  53. Generates pseudo-random float between ``from`` and ``to``, inclusive.
  54. .. _class_RandomNumberGenerator_method_randfn:
  55. - :ref:`float<class_float>` **randfn** **(** :ref:`float<class_float>` mean=0.0, :ref:`float<class_float>` deviation=1.0 **)**
  56. Generates normally(gaussian) distributed pseudo-random number, using Box-Muller transform with the specified ``mean`` and a standard ``deviation``.
  57. .. _class_RandomNumberGenerator_method_randi:
  58. - :ref:`int<class_int>` **randi** **(** **)**
  59. Generates pseudo-random 32-bit unsigned integer between '0' and '4294967295', inclusive.
  60. .. _class_RandomNumberGenerator_method_randi_range:
  61. - :ref:`int<class_int>` **randi_range** **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)**
  62. Generates pseudo-random 32-bit signed integer between ``from`` and ``to`` (inclusive).
  63. .. _class_RandomNumberGenerator_method_randomize:
  64. - void **randomize** **(** **)**
  65. Setups a time-based seed to generator.