Giter Site home page Giter Site logo

hungergames's People

Contributors

chadamiller avatar jakepusateri avatar jamespeerless avatar maxtower avatar sawatzkylindsey avatar timvermeulen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hungergames's Issues

Improved printing

I forked Game.py and changed it so it would keep track of eliminated players. It would use those to print a clean list with all finalists in order of food left, and all eliminated players sorted on the round they were eliminated. However, there's one problem left in my code, and I wasn't able to fix it (I'm new to Python). Should I just post a pull request so you can have a look?

Unnecessary divide by 2

I believe that the //2 here is unnecessary and causing everyone to die off too quickly due to never earning the bonus.

Printed reputation

In the last print, some reputations seem to be screwed up. Those screwed up reps seem to have a food value, but it is different from the amount of food that player has. Quite strange.

Mistake in rep calculation

Someone mentioned this on Brilliant's forums. The mistake is that I add the attempts in to total attempts before calculating rep, which means everyone's rep is too low.

Public Good award is incorrect.

Each round, your tribe can save some time and hunt extra food if enough people opt to hunt. Each round, a random integer m, with 0<m<P(P−1) will be chosen. If the sum of the number of times players choose to hunt is greater than or equal to m for the upcoming round, then everyone in the tribe gets 2(P−1) extra units of food after the round, which means that on average everyone gets 2 units of food per hunt. Before each round, you will find out the value of m.

However, in the code (lines 123 - 124; Game.py) :

    if total_hunts >= self.m_bonus:
        bonus = m

Looks like it should just be:

    if total_hunts >= m:
        bonus = self.m_bonus

I need a better name for the Player base class

I don't want to remove the base class entirely. However, I've decided that my goal for this project is to set it up so that if they have a working solution, they can just copy/paste the relevant class definitions from Players.py and have a working solution. This would also make the class file pass the verification script.

This is going to sound silly, but the only reason I didn't fix it before even posting this repo in the first place is that I didn't have a better name. I still really don't. Eventually I'll just pick something but in the meantime if someone has a better idea I'm all ears.

Return error in Game.py?

Correct me if I'm wrong, but in the top section of the Game.py file where it returns the payout, it appears to be returning the net payout (food recieved minus the cost of hunting or slacking). However if s1 chooses to slack and s2 chooses to hunt, it gives a net payout of 3. Is that supposed to be 1? (slacking costs 2 food, but s1 gains 3 food from s2 hunting)

Simulator doesn't work?

The simulator doesn't seem to work?

luis@debian:/git/software$ git clone https://github.com/ChadAMiller/hungergames.git
luis@debian:
/git/software$ cd hungergames
luis@debian:~/git/software/hungergames$ python app.py
Playing the game to the end:

Begin Round 1:
Traceback (most recent call last):
File "app.py", line 11, in
game.play_game()
File "/home/luis/git/software/hungergames/Game.py", line 170, in play_game
self.play_round()
File "/home/luis/git/software/hungergames/Game.py", line 121, in play_round
print ("There were {} hunts of {} needed for bonus".format(total_hunts, m))
ValueError: zero length field name in format

Argument passed to hunt_outcomes()

In hunt_outcomes(food_earnings), food_earnings should be a list of earnings from each hunt but instead it is a single number. This can be fixed by changing

player[0].hunt_outcomes(food)

in Game.py to

player[0].hunt_outcomes([ result[i] + {'h':-6, 's':-2}[strat[i]] for i in range(len(result)) ])

hunt_outcomes(food_earnings) does not match official requirements

"food_earnings: list of integers, the amount of food earned from the last round's hunts. The entries can be negative as it is possible to lose food from a hunt."

As far as I see it, you code neglects the cost of hunting/not hunting (-6/-2) and it only gives the sum of the hunting results instead of the list.

printing a player with no name raises ValueError

It turns out this bit:

def __repr__(self):
        try:
            return self.name
        except AttributeError:
            return NotImplemented

Doesn't do what I wanted it to. The intent was that people could set a .name attribute on their custom classes for better printing, but that Python would fall back on a sensible default if that attribute doesn't exist. It seems like there should be a sensible way of "Call this attribute if it's defined, but do whatever you would normally do if it's not" but I don't know what that is offhand. In the meantime you can work around it by always defining self.name in your initializers.

AttributeError: 'Player' object has no attribute 'name'

Just downloaded your files and ran app.py. I get this error message after round 774 when the game completes. I'm pretty new to this so I could be just doing some wrong or it might not be designed to work out of the box. Just a heads up, thanks for the code!

`player_reputations` in `hunt_choices` in does not match official implementation

Per this comment

everyone's reputation_list is unique to them (since they aren't in it) so it is mutable and doesn't hurt anything if they change it (except it may cause their own results to be different than they intended, though I guess it may be a useful tactic to do some in place modification of the reputation_list).

My reputation_list is a tuple and therefore immutable. The worse problem is that it includes the current player. play_round currently hacks around this, but forcing the Player subclasses to behave differently from the final answer is a problem.

Unexpected Issue

I'm getting the error
Traceback (most recent call last):
File "D:\hungergames-master\app.py", line 27, in
game.play_game()
File "D:\hungergames-master\Game.py", line 185, in play_game
self.play_round()
File "D:\hungergames-master\Game.py", line 115, in play_round
strategy.insert(i,'s')
AttributeError: 'NoneType' object has no attribute 'insert'

This error only occurs near round range 550-700 and never happened before. Why do you think this is occuring?

Request: Add a random bot

I think it would be nice to have a default bot who makes all decisions with a fair and independent coin toss. Thanks.

Engine does not test for invalid hunt_choices

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.