承接 sunsevennv/xorshift 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sunsevennv/xorshift

Composer 安装命令:

composer require sunsevennv/xorshift

包简介

Random number generator (RNG) by Andreas Madsen & Emil Bay

README 文档

README

Pseudorandom number generator using xorshift128+

Certified RNG using javascript (for gambling related games)

This module was written by Andreas Madsen & Emil Bay and modified by Brendan Nash in order to be certified under a UK, Malta and Curacao Gambling License.

The module is free to use in line with the original authors intentions.

Gambling License & RNG Certification

Should your organisation require an RNG certificate in order to obtain a gambling license, we can provide you with a certificate for this module.

You can place your order here: https://gtec.curacaowebhosting.com/cart.php?gid=9

  • email: brendan [at] gamblingTec.com
  • WhatsApp: +44 (0)7498 105896
  • Skype/Telegram: brendanjnash

Installation

npm install xorshift

Example

var xorshift = require('xorshift');

for (var i = 0; i < 10; i++) {
  console.log(xorshift.random()); // number in range [0, 1)
}

Documentation

This module exports a default pseudo random generator. This generators seed have already been set (using Date.now()). If this is not suitable a custom generator can be initialized using the constructor function xorshift.constructor. In both cases random numbers can be generated using the two methods .random and .randomint.

var xorshift = require('xorshift');

xorshift.random()

This method returns a random 64-bit double, with its value in the range [0, 1). That means 0 is inclusive and 1 is exclusive. This is equivalent to Math.random().

console.log(xorshift.random()); // number between 0 and 1

This method will serve most purposes, for instance to randomly select between 2, 3 and 4, this function can be used:

function uniformint(a, b) {
  return Math.floor(a + xorshift().random() * (b - a));
}

console.log(uniformint(2, 4));

xorshift.randomint()

This method returns a random 64-bit integer. Since JavaScript doesn't support 64-bit integers, the number is represented as an array with two elements in big-endian order.

This method is useful if high precision is required, the xorshift.random() method won't allow you to get this precision since a 64-bit IEEE754 double only contains the 52 most significant bits.

var bview = require('binary-view');
console.log(bview( new Uint32Array(xorshift.randomint()) ));

xorshift.constructor

This method is used to construct a new random generator, with a specific seed. This is useful when testing software where random numbers are involved and getting consistent results is important.

var XorShift = require('xorshift').constructor;
var rng1 = new XorShift([1, 0, 2, 0]);
var rng2 = new XorShift([1, 0, 2, 0]);

assert(rng1.random() === rng2.random());

A XorShift instance have both methods random and randomint. In fact the xorshift module is an instance of the XorShift constructor.

Reference

This module implements the xorshift128+ pseudo random number generator.

This is the fastest generator passing BigCrush without systematic errors, but due to the relatively short period it is acceptable only for applications with a very mild amount of parallelism; otherwise, use a xorshift1024* generator. – http://xorshift.di.unimi.it

This source also has a reference implementation for the xorshift128+ generator. A wrapper around this implementation has been created and is used for testing this module. To compile and run it:

gcc -O2 reference.c -o reference
./reference <numbers> <seed0> <seed1>
  • <numbers> can be any number greater than zero, and it will be the number of random numbers written to stdout. The default value is 10.
  • <seed0> and <seed1> forms the 128bit seed that the algorithm uses. Default is [1, 2].

License

This software is licensed under "MIT"

Copyright (c) 2014 Andreas Madsen & Emil Bay

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

sunsevennv/xorshift 适用场景与选型建议

sunsevennv/xorshift 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「unity」 「RNG」 「random number generator」 「xorshift」 「gamblingtec」 「gambling rng」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sunsevennv/xorshift 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sunsevennv/xorshift 我们能提供哪些服务?
定制开发 / 二次开发

基于 sunsevennv/xorshift 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 12
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-30