Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any real examples of how to use this with PHP? #2

Open
jpruiz114 opened this issue Oct 5, 2015 · 2 comments
Open

Any real examples of how to use this with PHP? #2

jpruiz114 opened this issue Oct 5, 2015 · 2 comments

Comments

@jpruiz114
Copy link

No description provided.

@jpruiz114
Copy link
Author

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,

@ALSchwalm
Copy link
Owner

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)   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants