foresight icon indicating copy to clipboard operation
foresight copied to clipboard

Any real examples of how to use this with PHP?

Open jpruiz114 opened this issue 9 years ago • 2 comments

jpruiz114 avatar Oct 05 '15 15:10 jpruiz114

I'm excited about this library, just installed it but I can't see any way to use this with PHP for example.

Can you provide examples to predict outputs for Java and PHP?

Thanks,

jpruiz114 avatar Oct 05 '15 15:10 jpruiz114

Using the lib for any platform is pretty much the same. You just import the one you want and the functions you need, then call from_outputs to get a generator yielding the future outputs. For example, suppose you had some outputs from the java function nextInt, you could predict the next values like:

from foresight.java import nextInt
previous_outputs = []

# put code here to add prior outputs to 'previous_outputs'
# ....

for future_output in nextInt.from_outputs(previous_outputs):
    print(future_output)   

A similar approach will work with PHP. Just use from foresight.php import rand. You will also need to specify a 'platform' in the php from_outputs call, because the RNGs are different on windows vs linux. So:

from foresight.php import rand
previous_outputs = []

# put code here to add prior outputs to 'previous_outputs'
# ....

for future_output in rand.from_outputs(previous_outputs, platform="windows"):
    print(future_output)   

ALSchwalm avatar Oct 05 '15 15:10 ALSchwalm