Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by chomps32 · Jul 07, 2016 at 04:57 PM · multiplayerrandommathrandomization

Algorithm for number generation that is random but consistent

I am trying to make a number generator that will create a random number but as long as the input number is the same the output will be the same. Does anybody know of an article for generating an algorithm that will do this?

  • I do not want a consistent output for each input.

  • I also want the algorithm to be low cost. It is going to be run many times on a weekly basis and the game is going to be mobile based.

One idea I have is to use the date in the input for the algorithm, that way it is consistent among the players, but it will create a different output for each input on a daily basis.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · Jul 07, 2016 at 05:38 PM

You appear to contradict yourself:

  • "As long as the input number is the same the output will be the same"

  • "I do not want a consistent output for each input"

Which behaviour do you want?

RNGs don't have an "input": they generate a sequence of numbers using an algorithm based on a seed value. If you supply the same seed, you'll get the same sequence.

You haven't said what you need the number for, but it sounds like you might be looking for a hash function instead, which generates a deterministic output from any input.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nikaas · Jul 07, 2016 at 05:51 PM 0
Share

Yes, he contradicts himself. He probably means he wants something far more "varied" than say y=3x+5.

avatar image chomps32 · Jul 07, 2016 at 06:03 PM 0
Share

@tanoshimi: I want a number generator for my social game that changes the in game economy globally. So, lets say an item has a value of 13 one week, the next week I would like it to have a different value, but the same value for every user. When I say I don't want a consistent output, I mean I don't want it to be a function that says, if value = 13 then value = 15. I want something more along the lines of if value = 13 and date is 3/03/16 then value = 15. Does that make sense?

Sorry for the confusion, I'm not always the best at explaining myself.

avatar image NoseKills chomps32 · Jul 07, 2016 at 08:10 PM 0
Share

I don't think this is a good answer. Please post comments as comments :)

avatar image tanoshimi chomps32 · Jul 07, 2016 at 08:10 PM 0
Share

If it's a social game you have clients that connect to a server? If so, just generate this week's random number on the server using any method you like, and let all the clients synchronise to that value rather than generate it themselves...

avatar image
0

Answer by mmehrten · Jul 16, 2016 at 06:55 AM

You could generate a sequence that you store on a server and then send to clients, assuming that your users are connected to a webserver. Or you could deploy the game with a list of ~1000 sequences and just use a different list item every day.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Network | Math: Smoothly lerp between inconsistent intervals 0 Answers

Random death instantiate? 1 Answer

Math question about random range and fractions 2 Answers

Normal distribution random 3 Answers

Network | Math: Smoothly lerp between inconsistent intervals 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges