ActionScript 3的实施Random.Next的() [英] Actionscript 3 implementation of Random.Next()

查看:157
本文介绍了ActionScript 3的实施Random.Next的()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果在AS-3很好地执行Random.Next的。

I was wondering if there is good implementation of Random.Next in AS-3.

基本上要产生一系列给定的种子的随机数,并在时间 的最小和最大限制。

Basically want to generate a series of Random numbers given a seed,and at times minumum and maximum limits..

类似于C#System.Random类。

Similar to C# System.Random class.

Random random = new Random();  
return random.Next(min, max);  

感谢所有。

推荐答案

格兰特具有随机数类,以及种子随机数类:

Grant has a random number class, and a seeded random number class:

非种子: http://www.gskinner.com/blog/archives /2008/01/source_$c$c_ran.html

种子队: http://www.gskinner.com/blog/archives /2008/01/source_$c$c_see.html

此外,您还可以在这里找到一个体面的实现:

Also, you can find a decent implementation here:

http://lab.polygonal.de/?p=162/

例如:

package{
  import flash.display.Sprite;
  import de.polygonal.math.PM_PRNG;

  public class RandomTest extends Sprite{

    public function RandomTest(){
      var random:PM_PRNG = new PM_PRNG();
      random.seed = 1234567890;
      for(var i:uint = 0; i< 10; i++){
        trace(random.nextDouble());
      }
      trace("----------");
      random = new PM_PRNG();
      random.seed = 1234567890;
      for(i = 0; i< 10; i++){
        trace(random.nextDouble());
      }
    }
  }
}

这篇关于ActionScript 3的实施Random.Next的()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆