Banana
2008-06-05, 22:23
I'm pretty sure this exists in some form, but may not know the right keyword to google it effectively.
I'm looking for information on how to implement something that creates more or less determinative result based on an input data to semi-randomly select something else.
Pseudo code:
public int(string foo)
{
int bar; int iter;
bar = foo.toInt();
iter = rand(bar, 0, 7); ///Selects a number between 0 to 7 based on the value of bar
return iter;
}
The idea is that the rand function, like any hash functions, would always produce the same result for same input but give different result for different result with no discernible pattern between a set of inputs to set of outputs. Therefore, the standard rand() won't do it for me.
Does such function exists? Any pointers will be much appreciated.
I'm looking for information on how to implement something that creates more or less determinative result based on an input data to semi-randomly select something else.
Pseudo code:
public int(string foo)
{
int bar; int iter;
bar = foo.toInt();
iter = rand(bar, 0, 7); ///Selects a number between 0 to 7 based on the value of bar
return iter;
}
The idea is that the rand function, like any hash functions, would always produce the same result for same input but give different result for different result with no discernible pattern between a set of inputs to set of outputs. Therefore, the standard rand() won't do it for me.
Does such function exists? Any pointers will be much appreciated.