Comments (15)
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.
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.
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.
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.
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.
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.
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.
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.
ok I'll use that, looks good to me
from hungergames.
Made a pull request, review it before pulling but I will be testing it a little more right now.
from hungergames.
What does the @@
notation do?
from hungergames.
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.
Oh, I think I misinterpreted your question. The @@ in git means that the lines of code moved without changing.
from hungergames.
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.
Just pushed James' fix.
from hungergames.
Related Issues (20)
- Printed reputation HOT 3
- I need a better name for the Player base class HOT 1
- Improved printing HOT 4
- hunt_outcomes(food_earnings) does not match official requirements HOT 6
- Argument passed to hunt_outcomes() HOT 1
- Return error in Game.py?
- printing a player with no name raises ValueError
- Each player begins the game with 300(Pā1) units of food HOT 1
- Unnecessary divide by 2 HOT 2
- I should write some tests for this thing HOT 1
- hunt_outcomes() gives outcome of hunt with one's self HOT 2
- Request: Add a random bot HOT 5
- Alternator bot does not behave like sample code HOT 1
- Public Good award is incorrect. HOT 1
- Simulator doesn't work? HOT 2
- AttributeError: 'Player' object has no attribute 'name' HOT 3
- Call to hunt_outcomes includes payout of player with herself HOT 1
- Unexpected Issue HOT 2
- Engine does not test for invalid hunt_choices
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hungergames.