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

differnt figure plotted when running mc.py #1

Closed
zhiyunq opened this issue Feb 7, 2019 · 4 comments
Closed

differnt figure plotted when running mc.py #1

zhiyunq opened this issue Feb 7, 2019 · 4 comments

Comments

@zhiyunq
Copy link

zhiyunq commented Feb 7, 2019

Here is what I got from running mc.py unmodified:

image

Any idea why it would be different?

@zhiyunq
Copy link
Author

zhiyunq commented Feb 8, 2019

OK. Found the bug which caused the issue: it is in environment.py

if np.random.random() <= 1/3:

The condition is always false because 1/3 is evaluated to 0. So effectively the card values are never negative as described in the game rules.

Changing it to the following will generate the correct figure:

if np.random.random() <= 1.0/3:

@zhiyunq
Copy link
Author

zhiyunq commented Feb 9, 2019

One more update:

In python 3.0, 1/3 does evaluate to 0.3333...

I was using python 2.7.6, which evaluates to 1/3 to 0 apparently. Surprised to see this behavior discrepancy in python (still new to it).

@timbmg
Copy link
Owner

timbmg commented Feb 9, 2019

Right. Do you get a similar plot with python3?

@zhiyunq
Copy link
Author

zhiyunq commented Feb 9, 2019

Actually I don't have python3. But after changing "1/3" to "1.0/3" the plot changes to what you have.

@timbmg timbmg closed this as completed Feb 10, 2019
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