2. Yes, it's alot easier to assess correct code behaviour if you know the input... Of course it is important to have several, including patological, sequences of nonrandom for a good suite of tests. :o) | [reply] |
Sure. But, you store your pathological sequences for testing, often in something like DBM::Deep. This didn't sound like a testing problem.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] |
In the game I'm writing, we have a coordinate system (x,y,z, with z representing the planet number). Moving from one coordinate to another is slow, but an advanced ability allows players to "jump" to nearby coordinates (distance <5 or so) where certain criteria are met. (basically a player action needs to be performed on the starting point and the ending point.)
For every one of those special coordinates, there is a list of the surrounding special coordinates. I don't want to directly give out which coordinates a certain "jump" results in, so instead they get a letter identifying each "jump" possible from the current spot.
The idea here is that the coordinate is the randomness telling how to shuffle the coordinates. This way, the jumps from a given coordinate are consistent forever in the future so they could record them and say "oh, to get to (1, 2, 5) from (10, 2, 4) I can jump A, C, G, Y."
The alternative is to generate the list of jumps once and store it. I do not want to do this, since the coordinate lists won't be used too often. The seed is already there in the form of the coordinates. The major problem, though, is the addition of a coordinate to the list of jumps. I would have to update every neighboring coordinate list. Removal would be a similar pain, and I'd need to ensure that the other items aren't disturbed.
There are also other applications that I have in mind, but this is the one that would benefit from this the most. | [reply] |
What about creating your own randomness algorithm? They're pretty simple to write and you don't need all the crazy stuff that most randomness algorithms need. Something like:
sub next_random_number {
my ($prev_number) = @_;
$prev_number ||= 0;
return ($prev_number + 14412312 ) / 123142131;
}
Now, that obviously wouldn't be good enough. But, you just need to generate and store the algorithm that comes up with the list, whatever that is.
An alternative which comes to mind (given that you're only doing this every so often) is to spawn a new process to come up with the shuffled list and let that process have its random number generator set. That way, the parent process is still fine, but you're able to set the stuff properly.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] [d/l] |