Giter VIP home page Giter VIP logo

Comments (15)

jamespeerless avatar jamespeerless commented on August 13, 2024

I JUST noticed this and then I switched to stepping through using play_round and the issue seemed to vanish, makes sense now. Are you going to fix this now or should I look at it?

from hungergames.

ChadAMiller avatar ChadAMiller commented on August 13, 2024

If I were fixing it right this instant I'd be writing the code instead of posting, so knock yourself out. And thanks. :)

from hungergames.

ChadAMiller avatar ChadAMiller commented on August 13, 2024

you are modifying how player i chose to play against the ith player in the reputation list, which is not himself.

It's not? Because that was the intent.

In the new version it seems like this isn't necessary as each player doesn't even return a strategy for how they'd play themself.

While the current solution of making players slack against themselves is kind of hacky, it makes the payouts easier to calculate. Particularly since it allows this:

for i in range(self.P):
    for j in range(i+1, self.P):
        if i != j: # actually come to think of it why is this "if" even here
            results[i][j] = results[j][i] = payout(strategies[i][j], strategies[j][i])

from hungergames.

jamespeerless avatar jamespeerless commented on August 13, 2024

Yeah I just removed my comment, I realized I was wrong.

Is that if there to prevent the last player from playing himself? This is my first time programing python so it's a little new to me.

from hungergames.

jamespeerless avatar jamespeerless commented on August 13, 2024

Makes the fix much easier too, just need to del reputation from list before calling hunt_choices and then insert the dummy 's' as their choice after. Cool. thanks.

from hungergames.

ChadAMiller avatar ChadAMiller commented on August 13, 2024

yeah, the "if" was to keep a player from playing himself, but the bounds of the ranges already does that. A friend laughed at me for calling Game.play_round embarrassing, but all the bugs and wtfs are coming out of there. ;P

Careful, del shifts the entire list which may not be what you want. Probably a better solution would be to use enumerate with slice notation:

reputation_list[:k]+reputation_list[k+1:]

where k is the index of the player to be removed. This creates a mutable list for the Player, but one that is never used again so we don't have to worry about bad player code messing up the game. This is what I would do if I were coding on this today.

from hungergames.

jamespeerless avatar jamespeerless commented on August 13, 2024

I copy the list before del and use that instead:

        # create a copy of the reputation list without this player in it
        player_reputation_list = list(reputation_list)
        del player_reputation_list[i]

        strategy = p[PLAYER].hunt_choices(self.round, p[FOOD], 
                            0 if self.hunt_oppurtunities == 0 else p[HUNTS]/self.hunt_oppurtunities,
                            m, player_reputation_list)

        strategy.insert(i,'s')
        strategies.append(strategy)

from hungergames.

ChadAMiller avatar ChadAMiller commented on August 13, 2024

ok. that works, though this is a bit more concise:

player_reputation_list = reputation_list[:i]+reputation_list[i+1:]

you can remove the del since it already excludes i

from hungergames.

jamespeerless avatar jamespeerless commented on August 13, 2024

ok I'll use that, looks good to me

from hungergames.

jamespeerless avatar jamespeerless commented on August 13, 2024

Made a pull request, review it before pulling but I will be testing it a little more right now.

from hungergames.

timvermeulen avatar timvermeulen commented on August 13, 2024

What does the @@ notation do?

from hungergames.

ChadAMiller avatar ChadAMiller commented on August 13, 2024

It's for decorators (kind of an advanced topic even within Python). @property in particular makes them similar to "getters" in OOP language. It's why self.P and self.m_bonus can stay updated even though I never manually update them; it calls those functions when it needs that value.

from hungergames.

ChadAMiller avatar ChadAMiller commented on August 13, 2024

Oh, I think I misinterpreted your question. The @@ in git means that the lines of code moved without changing.

from hungergames.

timvermeulen avatar timvermeulen commented on August 13, 2024

Ah, yeah, that makes sense. I was missing some function, but then I looked at the line number and it turned out it wasn't included due to the @@.

from hungergames.

ChadAMiller avatar ChadAMiller commented on August 13, 2024

Just pushed James' fix.

from hungergames.

Related Issues (20)

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.