For the game I am doing where the solar systems have x and y coordinates, I would like to use the coordinates to randomly generate functions for this solar system. The easiest way to do this seems to populate a random number generator with two seeds, x and y coordinates. Is there anyway to get one reliable seed from two seeds, or is there a good PRNG that takes two seeds and produces long periods?
EDIT: I know about binary operations between two numbers, but I'm trying to find a method that will lead to the least amount of collisions? Addition and multiplication will easily lead to collisions. But what about XOR?
. , , , , , , :
seed = (x << 32) + y
seed1 ^ seed2
( ^ - XOR)
^
PRNG 2 . , 10. , 1,5 ; , 1000000 10 ^ 6 1 500 000. :
Input "Enter power for 10^n modulus";m Mod& = 10 ^ m Input "Enter # of iterations"; n Input "Enter seed #1"; a Input "Enter seed #2"; b Loop = 1 For loop = 1 to n C = a + b If c > m then c = c - m A = b B = c Next
. .
- - 10. . , - - , . -, .
edit - - f1 = , f2 = G = (sqrt (5) + 1)/2....
- . Xn = Xn-1 + Xn-2 mod (G) mod (1) ( 0 1), , -,
, , , ...
, f1 f2 , , ...
counter = f1 = Xn f2 = Xn - -. ... Xn * .
, Xn Xn - - f1 f2, , , , .
.... , ...
, ? , , , , , ?
, .
, ( , - ). , , , .
PRNG :
http://www.math.uni-bielefeld.de/~sillke/ALGORITHMS/random/marsaglia-c
He clearly relies on two seeds, so he can only what you are looking for.
Source: https://habr.com/ru/post/1717453/More articles:Mystery pthread task with fork () - c ++How to create a "drag and drop target" in a winforms list that shows if the source falls before or after the target - telerikThe difference between C # and VB.NET for default values for private members is c #Разбор XML-ссылок в Delphi - xmlIronRuby-.NET 4.0 - Signs and exclamation marks at the end of method names - syntaxСравнение запросов для сравнения двух таблиц SQL Server - comparisonMySQL Connector: Parameters Not Added - mysqlMotorcycle database (make / model / year of manufacture) - data-modelingIs there a way to filter changes only for properties in the TortoiseSVN log? - svnI need a separate table to describe nvarchar (max) - sqlAll Articles