你如何获得随机在C#中的当前种子? [英] How do you get the current seed of random in C#?

查看:95
本文介绍了你如何获得随机在C#中的当前种子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的比赛,我将使用随机值挑奖励玩家从胸部得到。问题是,你可以快速保存和快速的负荷,这意味着他们可以继续再装上重新随机化,直到他们得到他们想要的东西。有没有一些方法,我可以得到我的随机对象的当前种子值,并可能返回到同一点时,他们负担,让他们不能滥用随机?

In my game I'm going to use random values to pick the reward the player gets from a chest. The problem is that you can quick save and quick load and that means they can keep reloading to re-randomize until they get what they want. Is there some way that I could get the current seed value of my random object and possibly return to that same point when they load so that they couldn't abuse the randomization?

推荐答案

不知道在获得种子,但你可以节省你给随机对象的值。记住,有两个构造函数。第二个是随机(Int32)已,所以如果你自己设置的种子(一个很容易值为 System.DateTime.Now.Millisecond ),将它传递给构造函数之前,你可以存储价值的地方。 :如果您还没有读过,在 HTTP检查MSDN文档//msdn.microsoft.com/en-us/library/system.random.aspx

Not sure on getting the seed, but you could save the value you give to the Random object. Remember, there are two constructors. The second is Random(Int32), so if you set the seed yourself (an easy enough value is System.DateTime.Now.Millisecond), you could store that value somewhere before you pass it to the constructor. If you haven't read it yet, check out the MSDN documentation at http://msdn.microsoft.com/en-us/library/system.random.aspx.

这篇关于你如何获得随机在C#中的当前种子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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