0

What I want to do is procedurally generate game content the same way every time it is rendered without having to render everything in the game until the player reaches that particular section of the game, by using a PRNG. I am trying to write a RTS space game. I want to also have a battle map on the planetary level where the player can control the units he/she owns. also the most battles with be fought in space. I want to procedurally generate stars, planets, moons, and when constructing ships or military units. I want particular thing to be generated the same every time. Same factions same game environment. Does anyone know any tips or articles that would help me? I have no clue how to set the PRNG to create content such as stars/w planets, etc.

user2864740
  • 60,010
  • 15
  • 145
  • 220
  • I believe this is not a good fit for SE. Well written, but just at the edge where you cannot judge which answers are better, because you have no key, no measure. Also asking for resources is frowned upon around here because these references tend to age and become invalid. – Palec Feb 08 '14 at 23:20

1 Answers1

3

Don't reinvent the wheel. Just use System.Random, which is a PRNG.

[The Random class] represents a pseudo-random number generator, a device that produces a sequence of numbers that meet certain statistical requirements for randomness.

Just construct the Random object with the appropriate seed.

Providing an identical seed value to different Random objects causes each instance to produce identical sequences of random numbers.

The actual usage of such is, well, a function of your generation code - but at least now you have a way of repeating the same "random" sequence on-demand ;-)


The algorithm used by Random might not be guaranteed across implementations, but such seeded usage will "be consistent" within the same environment. In any case, you can trivially use Random now and swap it out later if stronger guarantees are required.

user2864740
  • 60,010
  • 15
  • 145
  • 220