Skip to content
Snippets Groups Projects
Select Git revision
  • fdf2cfe5f14d8471adb831f2e544d91ce0c529bc
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

i18next.js

Blame
  • Dice.cpp 697 B
    #include "Dice.hpp"
    
    Dice::Dice() : mt_(), distribution_(1, 6)
    {
      std::random_device rd;
      mt_.seed(rd());
    }
    
    Dice& Dice::getInstance()
    {
      static Dice dice;
      return dice;
    }
    
    unsigned int Dice::roll()
    {
      // return (mt() % 6) + 1; // ist problematisch
    
      // Beispiel anhand eines 4-bit Integers, der Zahlen im Bereich [0, 15] darstellen kann.
      // Wahrscheinlichkeiten der einzelnen Zahlen des Würfels:
      // 1: 0, 6, 12 -> WSK = 3/16
      // 2: 1, 7, 13
      // 3: 2, 8, 14
      // 4: 3, 9, 15
      // 5: 4, 10    -> WSK = 2/16
      // 6: 5, 11
      // Damit ist das Ergebnis nicht "fair" bzw. gleichverteilt.
      // Daher besser wie hier drunter die Gleichverteilung verwenden. :)
    
      return distribution_(mt_);
    }