|
Replies:
3
-
Last Post:
Jul 9, 2007 12:01 AM
by: jwenting
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
Beginner Question
Posted:
Jul 4, 2007 11:41 AM
|
|
|
I'm just starting my journey into the world of Java programming and I'm finding myself a bit overwelmed. I'm using the NetBeans IDE to learn Java (On Ubuntu Linux) and am VERY impressed.
In order to learn the language I have decided to work on a fun project with no real world usefulness. I want to create a map generator to generate terrain data. I wanted to use a random number generator like Util.Random that accepts a seed number so that the map could be reliably reproduced simply by knowing the seed value. This is so that large map sectors could be regenerated when needed thus saving huge amounts of disk space.
I got to thinking however that if future versions of Random produce different numbers my map generator wouldn't be very good.
Is this a likely problem or are the numbers generated for a particular seed pretty reliable going into the future. What about on different platforms? Linux, OSX, Windows.
Thanks.
|
|
|
|
|
|
|
Re: Beginner Question
Posted:
Jul 5, 2007 5:13 AM
in response to: luft
|
|
|
Hi
This is a comment from the javadoc for java.util.Random ...
"If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers. In order to guarantee this property, particular algorithms are specified for the class Random. Java implementations must use all the algorithms shown here for the class Random, for the sake of absolute portability of Java code."
It is clear from this that your software should work across different JVM implementations/ platforms. Im not however sure if this guarantees "future proofing" of your code...
|
|
|
|
|
|
|
|
Re: Beginner Question
Posted:
Jul 5, 2007 11:44 AM
in response to: klopperq
|
|
|
I would say that one can rely on this contract to provide "future proof-ness" too. When the implementation is spelled out like that, another class would have to be created to provide a different algorithm.
|
|
|
|
|
|
|
|
Re: Beginner Question
Posted:
Jul 9, 2007 12:01 AM
in response to: erickson
|
|
|
unless of course the specification changes, but if you have to account for that all bets are off and you should really write your own language and compilers to run on your own operating system that works on top of your own hardware built in your own factories using raw materials from your own mines. Hardly appropriate for most applications.
|
|
|
|
|