Well all seems logical, but the one bit that is bothering me is that algorithm. How does it randomly pick a value from the predefined list ??
It isn't random. It's pseudorandom. Given the same seed, you'll always get the same number. PRNGs generate numbers that are difficult to predict without the seed so they look random.