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

Engine does not test for invalid hunt_choices #36

Open
ChadAMiller opened this issue Aug 15, 2013 · 0 comments
Open

Engine does not test for invalid hunt_choices #36

ChadAMiller opened this issue Aug 15, 2013 · 0 comments
Labels

Comments

@ChadAMiller
Copy link
Owner

I'm sorry I didn't consider this sooner, but if your hunt_choices is returning something that isn't a list, it will probably crash the game, and if it returns a list of the long length, it will probably have nonsensical results.

I would fix this bug, but between github outages and my being stretch for time I haven't really had the opportunity to add a fix and the deadline is in less than three days. Furthermore, anything I do would almost certainly behave differently from the server, which will purportedly replace errors with "all slacking".

Rather than tinker with this further and risk a last-minute screwup or expectation mismatch, I figured I'd just post what I'd do so people can do this locally if they want the sanity check.

In Game.py, outside of the class:

def valid_choices(L, n):
'''Sanity check for hunt_choices'''
    return (type(L) == list
        and len(L) == n
        and all(_ == 'h' or _ == 's' for _ in L))

In Game.play_round, after getting strategy from a player:

if not valid_choices(strategy, self.P):
    # handle errors however you want
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant