Main post link -> https://brilliant.org/competitions/hunger-games/
Hi all,
You may have received an email announcing our upcoming game theory themed programming competition. If you have any questions, feel free to direct them into this thread. You may have noticed that we now have a competitions page in the header. You can now look here for information about any special events and competitions we host that deviate from our weekly problem sets. As future competitions happen they will be announced in discussions, via email, and appear on that page.
We hope our Hunger Games serve as a fun way to explore the principles of Game Theory and give you all a break from the pursuit of the single integer answer.
Have fun!
Edit (7/22): Good questions from this thread have been collected and answered in the FAQ for easier reading.
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
I'm working on a sample test engine here: https://github.com/ChadAMiller/hungergames
One corner of the rules I'm not certain about: is it possible to go to negative food? That is, if I have 6 food left in a 3 player game can I still hunt twice (but still die if the other players don't hunt)?
I think I may have found a bug:
The rules say that: Each player has a reputation R, which is defined as R=H+SH, where H is the number of times you chose to hunt and S is the number of times you chose to slack (not hunt).
Although players start with 0 reputation, I think that's only for the first round. Afterwards, the reputation is not R=H+S+(P−1)H, but R=H+SH.
Are you saying it's right iff I switch those two lines? Because I think you might be right. Just waking up, but I'll look at it later.
ZeroDivisionError
that isChad, thank you so much for your testing environment and the ready-to-submit Player class. Made it very comfortable to participate.
Hey Chad, I forked your repo, and my partner Tim and I have re-factored some stuff. It makes the code more modular, and re-writes Game.py. It's probably less efficient, but I think it's more readable.
https://github.com/jknielse/hungergames-1
I took a closer look. I don't think I'll be merging it, though I definitely like some individual ideas (in particular, I think the
GamePlayer
class is better than the current global variable/tuple-based solution). While I'm not obsessing over performance, my gut feeling is that storing the entire game history as a list for the duration of the game is too loose.On a couple specifics that I think would be strict improvements: defining your own
add
forreduce
is generally slower thanfrom operator import add
which is generally slower thansum
. Rather than defining aPrint
method, you can overload__str__
or__repr__
so that your classes work sensibly with the builtinprint
.Awesome, I'll have a closer look tomorrow.
If you modify the script to give a comma-separated output, it will be easier to read the results in a table and plot/analyze them.
You noted that your class fails the test script. Wouldn't that imply that it will also fail in the actual competition, or am I missing something?
By the way, you can have negative food during the round. See this comment.
It fails the test script because the test script assumes that the actual entry is named "Player". A submitted solution could fix that problem with two lines of code.
Oh, and thanks for the link, I missed that the first time. The implementation should be correct otherwise, barring bugs.
"If after any round you have zero food, you will die and no longer be allowed to compete." I guess according to the rules, you're fine just as long as you have more than zero food by the time the round ends. Unless there's some sort of thing in the hunting function that doesn't let you hunt if you have zero or less food. I doubt it though, I think they'd be explicit about that sort of thing.
Right, they've confirmed in the FAQ that negative food during a round is fine, including initiating hunts with negative food.
Whenever my algo returns huntdecisions in which the number of elements are greater than the input-ed number of playerreputations your engine seems to make it unbeatable.
Huh? What is it doing in that case?
zip
discards excess length of the longer list so that's probably why. I don't want to mess with the repo until github fixes whatever bug makes pages take 10 minutes to load for me, but I was thinking of throwing in anassert
so that the program blows up by default if the player returns invalidhunt_decisions
. That's technically different from how the server will behave but I assume most people would like to catch that in testing.Can you submit more than one solution? (For e.g. I would like to submit one that will play to win and one that will play to survive)
Is it allowed or disallowed to collude with other algorithms (potentially your other submissions, submissions of your friends, etc.) based on agreements outside the game? (e.g. make 1 out of 100 a 'winner' and have the other 99 just help this chosen winner)
Are we allowed to try to deduce from the information presented who the other players (randomly permuted) are?
Are we allowed to break your PRNG (e.g. assume you use a standard a*X+b modulo p) to figure out all future randomness in the game?
Are we allowed to communicate (i.e. broadcast) to all other players before the submissions are made (e.g. make threats/offers or ensure that certain information is common knowledge)?
Thanks!
Salutations to all!
Reposting for visibility: how much time will our program get before your server decides that it is stuck in a loop and kills it? Along the same vein, what is the ram usage cap?
"After a large number of rounds, there will be a small chance each additional round that the game ends"
Any clarification on this point? I read this as after some fixed number of rounds N, for each round number > N there is some fixed probability P that the round will be the last.
Does P increase as the rounds go on? Any hint as to how N and P will be determined?
Yeah I have no clue how this is supposed to work either I think you're right. Wait I'll go check the FAQ.
I think that the staff does not want us to know how this works exactly, because we could then calculate the probability of the game ending each round, which we can use in our algorithms. I think we are supposed to not know at which round the game ends.
random.geomvariate()
. I could have rolled my own, but I doubt the difference between that and my "round the exponential" is significant.Can we use another programming language other than Python ?
We are currently evaluating the feasibility of allowing java as well. We'll be able to firmly answer this question shortly. Other languages are not planned at the moment.
Please tell us soon!
It's incredibly easy to learn too, so considering you're in Data Structures 4, you should have no problem completely understanding the constructs of Python.
Do you have a 'simulator' that would allow us to test our hungry programs?
Right now we have a test script that you can use to verify your code is functional.
I created one and it's hosted on Github at https://github.com/CaptSullivan/HungerGames
I think there's something that needs more clarification.
"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 total number of hunters 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" I think the bold portion should be sum of hunts of all player, right?
And in the sample code, "number_cooperators: integer, how many players chose to cooperate over the last round." What is cooperation? It is not defined. Moreover, what does it means that a player cooperated? Is is something like he did at least one hunt?
Thanks in advance :)
Another question about the word "average": Why would that be an average of 2? If the threshold is reached, then everyone gets exactly 2 per hunt, otherwise everyone gets exactly 0. Also there is no possibility to gain more than 2 extra food, so the actual average over the whole game is some number between 0 and 2. Am I missing something?
Correct. The bold portion means "sum of the number of times players chose to hunt in that round". We'll adjust the language to make it clearer.
As for number_cooperators: cooperator means you hunted. So this number is precisely the sum of the number of times players chose to hunt in the round. We'll modify the language here as well to streamline terminology.
rather than numbercooperators, would numberhunts not be better?
Hey, Peter.
First off, I really love this new Competitions feature. Some of the most recent updates to Brilliant show that you guys are dedicated to making this website better and better and that's great :)
I read through the rules for Hunger Games and just had one question: I have been a member of Brilliant for a few months now and I have two friends with whom I'd like to make a team. Unfortunately, they do not have accounts on Brilliant. Am I still allowed to form a team with them and submit my team's code through my account, or do they have to also make accounts (or are they maybe not even allowed to play)?
Your friends can definitely team up and play with you! Anyone with a Brilliant account can participate, and anyone who can beg, borrow, or steal time on a computer can create a Brilliant account. Please have them create accounts on Brilliant. They can do so directly on the Hunger Games page: https://brilliant.org/competitions/hunger-games/
If you are logged out or do not have an account when you see that page, hitting the "start playing" button prompts you to a sign up page. Just send your friends the link.
We want teammates to all have accounts on Brilliant, as it provides a layer of verification that the people who submit code, or supposedly submit code, are in fact who they say they are and not impostors, bots, cylons etc... With money prizes on the line this is important. It also provides us a way of informing all members of a team of the status of their algorithm in the competition, as opposed to just you.
Have fun and may fortune smile upon your strategy :)
Thanks for the information :) I'll relay it to my prospective teammates.
Clarification:
Is my food counted only at the end of the round? What will happen if I have negative food during the round, but manage to make my food positive at the end of the round?
Food is only counted at the end of the round.
By "end of the round", do you mean before or after the evaluation of whether total round hunts ('h's) > m?
Just for clarification: What are the specifications of the target computer (Python version, processing power, etc.)?
Python version would be nice to have indeed. I assume it's 3.x since test code uses print as a functions (can be done in 2.x too, but is necessary for 3.x).
we officially support 2.7 actually
Python version is 2.7, processing power is "enough", i.e. worrying about our specifications should not be a concern
Brilliant is awesome!!!
Request: Can we receive the actual tester code so that we can test our algorithms against others on our own local development machines?
I'll probably be writing one before too long. I can post it on github and put a link here if you'd like.
You might also want to look at mine: https://github.com/ChadAMiller/hungergames
I wrote one last night. It's fairly simple and straight forward. Should also be easy to read if you want to tinker with it. https://github.com/CaptSullivan/HungerGames
Since my git repo is picking up steam, I'd like to clarify a couple things to make sure we aren't leading each other astray:
-If we use an OOP solution, is it expected that our player class be called
Player
? Is it ok if that class inherits from another class in the same file? Are there any limitations on imports (from the standard library)?-Will all players be in the same tribe? Or do we stay in one tribe for some rounds, then the survivors get merged with another tribe later? Or is it possible that some players will never be in the same tribe with other players?
good points. Also:
I suggest a change: Give the extra 2 per hunt only to the actual hunters. This would make it in 50% (in case m follows a linear distribution) of cases worth the "investment", which means maximum unpredictability for dumb programs. This also opens up a whole new layer of depth: you would have to estimate the propability of number of hunts reaching the threshold. Also this would improve the next issue:
I would suggest a slight change of numbers. maybe make cooperating more beneficial, and/or consider the change to the public goods rule as stated above
(Assuming of course everyone is playing to win the game cause they want that $1000. Oh, and assuming that we are silly enough to not necessarily reward someone who had a great strategy to ensure survival with one of those other $1000 prizes...winning guarantees you a $1000 prize, playing to win does not necessarily increase your chances of one of the other prizes.)
Decisions, decisions!
By the way, the other 4 grand prizes. Do you give them to four most interesting/smart/innovative algorithms on avarage or do you have one for "Best game theory analyzing" and/or "Best choices on avarage" etc?
I understood the prize section as a decision help if many of the last programs are equally good and are more or less seperated by chance
As an example, assume the stated goal is to win (which will be the default). Then someone may design a strategy that assumes certain things about how the population plays (call it population A) and constructs a winning strategy. However, that strategy may be a losing strategy if the population plays differently (population B). Therefore that strategy is not completely robust and so not completely "efficient" in that it doesn't always reach the stated goal. It is however, eligible for the win prize.
Alternatively, someone could say that their stated goal is to win the t-shirt. They may construct a beautiful strategy with analysis that will never win against A or B, but will at least survive vs. both. This strategy is efficient in that it always reaches its goal. That goal won't make it eligible for the win prize, but it still may be worthy of one of the other awards. We don't want to pre-judge this aspect. How well you do in the game is certainly part of the other awards, but not all of it. So while there is an aspect of "judging help" between equally good algorithms separated by chance, that is not the only thing the extra awards can be for.
In terms of game play, all I will do is caution you against the assumption that everyone is playing to win the game. Some may be just playing to survive, and this may make them view the public good option differently, as they don't really care how you do, only how they do.
To be clear, P is recalculated per round, correct? I.e., if the round starts with 300 players and one player dies, P=299 in the subsequent round?
On winning, the rules state, "The winning algorithm is guaranteed to receive the Grand Prize." What if P players all die, resulting in the end of the game? Who is declared the winner? The one with the "least" negative score? What if there are ties?
This needs to be clarified on the rule page. I am confused as well. I would assume so.
From a previous response from Staff, YES, it is the living players at the start of the round.
From the FAQ.
If the last N players all die in the same round or N players have the same food at the end of the game, then reputation will be used as the tiebreaker, with the highest reputation winning. If there is still a tie, then the winning prize will be split.
So if N players die at the end and they are all left with -1 food, then reputation will be used to break the tie. Those with the same reputation will split the grand prize.
I have made a pdf to explain my strategy as stated in "The algorithm (and separate document, if any) should be submitted", but in the submission form, I can only post 1 files... Where should I put this separated document ?
What about a .zip or .rar file?
zip or rars will probably not be allowed, but we've modified the form to allow a second upload which should be a pdf, txt or md (markdown) file. If you have already uploaded a non-python file, please reupload following the new conventions (One python file and one pdf txt or md file) or your submission will probably not be entered into the competition.
When is code going to be run?
Let the games begin!..Two hours to go,but it's almost midnight here.Im hitting the sack.
And may the odds be ever in your favor. Just had to say it :D
Hello, some questions about the rules.
1) 0<m<P(P−1) This means that 'm' can be higher than 'P' ?
2) "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"
Everyone in the tribe or the tribe receive the bonus? If is everyone so the average is higher than 2 units.
Thank you.
If everyone gets 2(P−1) units, then that is 2 units per (potential) hunt, as everyone has P−1 chances to hunt.
So that would imply if I and you were players in the tribe, then in each round, there will be two hunts which includes us. For if it was not like that, then there should have been (2P) hunts.
m. That number of hunts is first counted for each individual, and then added together. So, there is just one hunt which includes us. If at that moment, we both choose to hunt, it's counted once for me and once for you, so twice in total. If only one of us chooses to hunt, then the total number of hunts (which will be compared to m) is only incremented by one.
In order for the bonus to apply, the total number of hunts needs to be at leastBut it says that everyone gets the bonus. And this 2(P−1) will always result in 1.9... per player. So why just said 2 per player? I´m missing something? (Or is everyone that hunt this turn?)
P−1 times. So if you get 2(P−1) food, that's 2 food per (potential) hunt.
Everyone can huntIt should also be noted that you get the bonus food regardless of whether or not you hunted.
This. Is. AWESOME!
I love this competition.
Is there a check on ip's of the player who partecipates to the game? To prevent the creation of many account and that the same player submits more codes...this'll be unfair of course ;)
A couple of questions:
I'm bumping this. It's really, really, really important to know what the limits are regarding computation time and memory limits. They will have limits to these to keep people from sending them things like:
while true: pass
or
i = 0 while true: k[i] = "stuff" i++
Do not worry about time limitations or ram usage at the moment. We will try to be very lenient and not implement any hard caps. Algorithms that appear to be taking a long time or using tremendous amounts of ram will be inspected by staff before a decision is made to kill it, and a great algorithm that simply takes a long time/uses lots of memory will not be killed. This is, after all, an analysis competition, not a programming competition for algorithm speed or efficiency.
That said, if we found an algorithm like yours above, it would be removed, with prejudice.
You can test your program for common mistakes using a script, see the Sample Code section.
Is reputation rounded, or is it just casted as a type double?
When must submissions be made by. Midnight on Saturday 17th or midnight on Sunday 18th? And what time zone (I'm based in Hong Kong)?
Like all good students I like leave things to the last minute...
I just put up a timer, basically, the form will be disabled when the next set of problems is released on midnight sunday (UTC).
Hi Guys, I have a clear idea how my logic should be and it is a very simple one. That should not be too difficult to program, but given the looming deadline, I finally lost my last hope that I would teach myself enough Pyton to code it myself alone, without help...
Basically my inspiration is sourced from the inventor of this "iterative prisoners dilemma tournament" concept = Robert Axelrod and its first winner = Anatol Rapoport.
Tit for Tat (TfT) was the simplest of the algorithms in in the first incarnation of such tournaments 30 odd years ago - and surprisingly the most successful one... round after round despite evolving competition!
I have a hunch that it should still fare well, simple and elegant.
Can anyone help me to convert this verbal logic into Pyton code.. or... Also happy to team up with any volunteers to for a virtual team ;)
OPTION 1 (preferred) * If you are meeting with your partner for the very first time = Hunt * If you meet the same partner again in the future: remember what was his behavior to you last time and play it back (H for H , S for S)
As you can see the algorithm is not using the partners (formal, general) reputation score but using the reputation from your point of view only.. You may say that you are not penalizing your partners for the "sins" that they have committed elsewhere (or for previous old defects to you. You don't hold grudge) This algorithm just replicates Anatol Rapoport's original TfT in the "Hunger Games" universe... Curious how this logic will fare...
OPTION 2 If option 1 is too difficult to realize, I can settle with this one as well.. Should be much simpler and I guess should be a 1 line of code: * Take your partners reputation score (e.g. 0.9) * Use this as an input to randomly decide to hunt (90 % probability) or slack (10 % probability)
More clever things can be done.. but I will stick to the simplicity and the ancient wisdom..
http://en.wikipedia.org/wiki/TheEvolutionof_Cooperation <quote> In summary, success in an evolutionary "game" correlated with the following characteristics: Be nice: cooperate, never be the first to defect. Be provocable: return defection for defection, cooperation for cooperation. Don't be envious:: be fair with your partner. Don't be too clever: or, don't try to be tricky. </quote>
Hope I am not breaking any rules by revealing a source from wikipedia (or my my logic for that mater) in the discussion board. If I am, accept my apologies. I am just following the TfT logic by heart. (be nice and cooperate!) and this includes cooperating with the ideas as well. Also let me declare, in the (unlikely) case that my entry is successful, I will donate the prize to my alma mater, in the true spirit of brilliant.org: promoting education and science... http://en.wikipedia.org/wiki/AnkaraScienceHigh_School
Thank you for the gentle soul who can help me with the Pyton coding in advance..
All the best, good luck in the competition!
Hakan
The players are shuffled every round, so your OPTION 1 as described requires information you don't have.
OPTION 2 is already implemented in my GitHub project as
FairHunter
if you want to see what the source code looks like (it's inbots.py
, inheriting from a base class inPlayer.py
). And you're right, it's a 1-line comprehension not countingimport
s.Very, VERY nice comment/post. The best alongside Chad's hunger games simulator post. I am sure this is what Brilliant staff was after when one of them said they even encourage to discuss about the best tactic. Like Chad side, first option requires one to connect players from last round with current round. It's not impossible especially after many rounds (50 or so, depends on how many players), but it can still be unreliable. Altho I am sure somebody implemented this kind of tactic already considering there is like 120 algorithms already participated (!!!), From what I have learned during force-test simulations (10 games of 50 players in ~7sec), from all simpler bots like one you described it performs a lot better. Could be just the fact I am using clones of same algorithms in one game and there's lack of proper algorithms, but it still wins other algorithms by a long shot.
I think a good distribution of players is 2 of a "smart" algorithm (hopefully your player), 4 of the Bounded Hunter, 4 of the Fair Hunter, 4 of the Alternator, 15 Pushovers, 70 Maximum Rep Hunters, 100 Average Hunters, and 75 Freeloaders. That's my own intuition; use this information at your own discretion.
What do you suppose the turn-around time will be once all of the submissions are in?
There will be "what happens next" post/email tomorrow with all this information.
According to my analysis, your earnings in a single round does not depend on who you hunt with, only how many times you hunt. Given a population P, a number of hunt choices H, and a number of opponent hunt choices G, the net earnings ΔS for a round is ΔS=3G−H−2P, no matter how the H hunts (and P−H slacks) are aligned with the G opponent hunts (and P−G opponent slacks). Can anyone else confirm this?
It's interesting because it means deciding how often to hunt and who to hunt with are two distinct problems, at least before tracking becomes a possibility. The algorithm should a) find an optimal value for R (in general) and H (this round), and b) distribute "sick" choices to players who might be winning. If R has been selected correctly, then the winning players are the ones with reputations close to R, so those are the ones not to hunt with.
Suppose that the population as a whole is roughly centered around the optimal reputation. A particular player who maintains this median reputation may perform very well absolutely, and if, in addition, this player targets opponents at the median reputation, it may be able to outperform other players, as well.
Looks right. Basically what these equations are saying is this: Your opponent's hunting with you is worth +3 to you, and their slacking with you is worth 0 to you. Your hunting with them is worth -1 to you, and your slacking with them is worth 0 to you. There's a -2 base payout (or 0 if a hunt bonus is awarded).
So, unless you can track individuals, what you're really looking at is trading your own hunts to the tribe in return for hunts from the tribe. It's worth trading three of your own hunts to get one hunt from the tribe. And, unless individuals can track you (and most probably can't), it doesn't matter who you give food to.
(Being able to track individuals' food would be interesting. Then, you'd want to copy the #1 guy's reputation, while at the same time starving as many top guys as possible so you could decrease their ranking relative to yourself. I wonder what kind of population dynamic this would lead to? Everyone with the same score? A constant churning of the leaderboard?)
You can know who has the most food, but you can suspect.
I ran some simulations using a bot that followed approximately this algorithm and it did surprisingly well. Your analysis here takes some of the surprise out of the result.
Another odd thing I found is that there were really two end-game equilibria: one where everyone starves, and one where everyone has more food than they know what to do with. The break-even point seems to be around a 50:50 hunt:slack ratio, where if the average among everyone is below that, everyone will eventually starve, and above, there is ridiculous amounts of food for everyone. Different bots flourish in each environment, so it will be interesting to see whether the starting conditions are primarily cooperative or hostile.
You mean your reputation does not depend who you hunt with, just how many times you hunted? Your earnings of course depend on who you hunt with. If you chose to hunt 3 times in a round and your opponents slacked you are -9, if all of them hunted you are at 0 (did not gain anything, but did not loose anything either). But you are right that decisions how many times to hunt in a round and who to hunt with are two different decisions. Whether or not you get a bonus depends on how many times you hunted and of course how many times others hunted, not who you hunted with; whether you loose -3 per hunt or not depends on who you choose to hunt with.
If people chose how many times to hunt in a round regardless of the value of m, then the sum of hunts in a round for all players can approximated by a normal distribution. But for each player probability of hunting likely depends on m, it's not just the reputation.
I agree that many players probability of hunting will depend on m. I'm still not convinced that any player who wants to win, i.e. outperform other players, would hunt more or less depending on m. If anyone can shed some light on this, I would greatly appreciate it.
n rounds), my (non-bonus) earnings is entirely determined by
That's appealing, but I'm just not sure. At the end of the day (i.e.S=3∑i=1nGi−∑i=1nHi−2∑i=1nPi.
If I end up with a reputation of R=∑i=1nHi/∑i=1nPi, it doesn't matter if each choice of Hi was positively correlated with the mi, inversely correlated with mi, normally distributed (about RPi), or all the same (RPi).
Certainly m obscures your ability to tell how G depends on R, and you might want to factor it out when choosing a target value for R. But that wouldn't adjust any particular Hi based on mi in a given round.
The average effect of m on G will move the target R up or down, but I again, I wouldn't adjust any particular Hi; I would only care about the specific effect of mi on Gi in order to learn to subtract it out.
Hmmm. Your earnings do not depend on who you hunt with, only the number of times you hunt and the number of times your opponents hunt with you. Let me give you an example with 4 players (P=3). Let's say I decide to hunt twice (H=2), and it turns out that 1 opponent decided to hunt with me (G=1). My claim is that ΔS=3G−H−2P==−5, no matter who you hunt with. Consider these alternatives:
1 hh, 1 hs, 0 sh, 1 ss ⟹ΔS=1(0)+1(−3)+0(1)+1(−2)=−5
0 hh, 2 hs, 1 sh, 0 ss ⟹ΔS=0(0)+2(−3)+1(1)+0(−2)=−5
Let me take this a step farther, and say that your earnings across two rounds do not depend on how many times you and your opponents hunt in each specific round, only in the total hunts in the two rounds. That is, given Hi, Hi+1, Gi, and Gi+1,
ΔSi+ΔSi+1=3(Gi+Gi+1)−(Hi+Hi+1)−2(Pi+Pi+1)
so if you want to maintain a reputation of say 75%, it doesn't matter if you hunt 100% in round i and 50% in round i+1 or 80% in round i and 70% in round i+1 or 75% in both rounds. Of course, Gi+1 is not actually fixed at round i and (probably) depends on how your choice of Hi affects your reputation Ri+1 in round i+1.
I have a question. Is this fine with copyright laws? I mean, isn't the Hunger Games a registered trademark of some publisher or film company?
We believe it to be fine under fair use laws. A community of math and science enthusiasts, throwing a competition where algorithms compete for "food" is not going to be confused with the best-selling books and movie.
Haha that's funny. Okay. Doubts assuaged.
Oh my God, what amazing Brilliant works :)))
what can we do if we do not know the programming language (python) in which we have to write the program
Write in English. Add parentheses and colons. Now you have python.
I'd recommend this.
I recommend the book "Dive Into Python," which the author has made available for free online. It is targeted towards "experienced programmers," and will help you build a solid understanding quickly.
It's incredibly easy to learn. You're in Data Structures 2, and it will probably take you around 3 weeks if you sit down and learn Python to master the language. In fact, if you're familiar with some other language, grasping the basics of Python should only take you a day at a maximum.
No one truly masters a computer language in 3 weeks. Mastering a language means understanding every single detail of it and how it works in the computer. Source: I'm a college student in computer sciences.
I was only "annoyed" (not really, but you know what I mean) by the word "master".
Am I allowed to import random?
Yes.
Is P bounded by a constant, or instead, in round 1, will it be equal to the total number of players in the competition?
P is always the current number of players (see: section II, "Hunts")
I'm just concerned about performance with polynomial time algorithms over the number of players. I don't have a great way to predict the size of P, and I don't want my algorithm to be ejected for running too slow if P is larger than I anticipated.
https://brilliant.org/i/h0CPoQ/
For Practice Problem 5, unless I'm mistaken (which I easily could be), it looks like the practice problem is wrong. Chuck's optimal strategy is cooperate on round 1 and defect on round 2, which gives him 0 + 8 = 8 points total. This strategy is better than any strategy involving defecting on the first round, so he will always cooperate on the first round no matter what the bonus A is.
Is the problem incorrect, or am I missing something here?
Actually, it asks what should A be so that every strategy involving Chuck cooperating in the first round, is better or equal than every strategy involving Chuck deflecting in the first round
I was wondering this too myself, and just thought I misunderstood some of the English wrong in my head. Indeed if Chuck first chooses to cooperate (0) and then defect (8) he gains 8. I am now even more confused after I checked my answer which was 'right'.
What did you answer? We might deduce from that what the intended question is.
A, but just any A. So A=100 should be right as well, as Chuck then still is 'at least as satisfied with cooperating as with defecting'.
Thanks, got it right. Something else that bothers me about this question is that they're not asking for the smallest possibleI think Mihail's rewording of the question makes it a much better match for the correct answer. I was totally confused and thinking along the same lines as MIchael D, until I read Mihail's comment.
we're adjusting this problem. It's not phrased in the way we wanted it to be.
Somehow I can't find any other way to beat the player that always slacks in my simulation of the environment. The payoff table my team constructed gives slacking to be the pure strategy and the only Nash Equilibrium (there is no mixed strategy as well). On a round to round basis, there is no way to beat someone who always slacks. We may have misinterpreted the game rules so we are requesting for a clarification over the hunts mechanism.
Slacking is surely the best thing to do in a certain round, but for the long run, you might want to hunt, because that boosts your reputation. You want a high reputation because (hopefully) others are more likely to hunt with you if your reputation is high.
If your reputation is high then others should think you are likely to hunt and they will slack. Because if you hunt and they slack they can earn one food without doing anything.
In 2 players, always slacking is unbeatable. It's not with more. A strategy of "slack unless paired with someone tied for the highest reputation" will beat any number of slackers as long as at least two players are doing it.
Will there be any way to test whether our agents function (and thrive) before the deadline?
Yes and yes.
What I mean is will there be any way to test our agents against other competitors' agents before the deadline?
What happens in the event of a large 1st place tie?
Love this competition, combines some of my favorite things (game theory, programming, competing and prizes!). I would be excited to see an evolutionary game theory variant of this in the future, where successive generations inherit a "family" identifier (able to recognize your own "offspring/parents", but not necessarily which family others belong to), and a family reputation.
Hi, I was wondering if there were any guidelines for nomenclature of classes, since the validator specifically looks for a class named 'player'
It seems like you should just name your class
Player
upon submission. Whatever you name it during testing shouldn't matter.It's confirmed in the FAQ that the class should be named
Player
. This is the primary reason I adopted that convention in my github repo.thanks for the clarification! May I suggest putting a link to the FAQ in the large menu for the competition page along with Home ... Backstory so competitors will be able to find that page more easily
"Each round, a random integer m, with 0<m<P(P−1) will be chosen."
Is the random integer, m, chosen from a uniform distribution?
yes
My teacher got me to do this and I am only 12. I do not understand any of this stuff. Please can someone tell me what this is in a simplified form?!?
Wow, I was skateboarding and surfing when I was 12 haha... I'm impressed... Do you have any specific questions? Do you know how to program?
Yes I totally agree, this site is insane! Hanging around here is not good for my confidence!
What is the actual input in this game?
Do input the amount of players?
When i get the amount of players (P) do i input characters 'h' and 's' P-1 times for each of P players or just for 1 after each round?
How do i know how many rounds are there and what is the chance that i get another round after all of them end?
Did i get this right: after every period of hunting if both go they get 0 food, if none goes hunting both of them lose 2 food and if one goes and one stays they get: 26+0−26+2=3−4=−1? Shouldn't that mean that they should always go hunting?
1) described in the sample code 2) described in the sample code 3) the probability of any round ending is "small". It's very intentional that you never know if the game is about to end or not 4) If one goes and one stays, the one that goes spends 6 while the slacker only spends 2, but they both get 3 back. So the hunter gets -3 while the slacker gets +1. The goal is to try to get other people to hunt with you.
In simple game theory terms, the dominant strategy is to always hunt, but the equilibrium for the game (in the simplest case of two players) is to always slack.
Can you explain your reasoning for calling "Always hunt" dominant?
Well... Do rounds begin at round 1 or at round 0? Just to be sure. By the way, does someone have an idea of what the initial population will be? There were more or less 700 people who answered the first exercise problem, do you think that would be a good indicator? Or are there people who plan to participate and did not answer it (like me...) and/or people who answered it and do not plan to participate???
The first round number we send to hunt_choices is 1.
If we go with the OOP solution, can we define and assume access to global-level functions or should we stuff them all in our class.
e.g. if I want to write:
Do I have to put it in my class and call
self.mean
or can I leave it global and just callmean
That should work though I haven't extensively tested it. I believe python is pretty good about figuring out what information different objects should have (and preventing unintended access (for instance, if someone had
def sum(x, y):
in their code, it wouldn't override python's defaultsum
function for other people).will it use
importlib
like in thetester.py
script? If so I could probably figure out the answer myself within the day.importlib
. If your code works with something like that it should work.To be clear, what I did test was that you can define a function outside of the Player class and have it be called from within a method of Player class, what I didn't test were any of the conditions where there could be unintended access or something like that (which I'm pretty sure is not an issue).
That email was helpful. 118 is a good reference number.
How does my reputation effect my outcome in the games?
If I understood well, you could choose to hunt or not hunt a player according to his reputation. If a player has a reputation of 1 he has always hunted, while if it's 0 he never did it!
So I have a few weeks to learn programming... ok! I love the picture under "Backstory"; did Brilliant staff create it?
Yep, that was us! :)
Well, seriously I am a big enthusiast of programming, but a thing hinders me here. Can I write the code in pure JAVA language?? That would be of great help.
If you know Java well, learning enough Python for this project should be very easy.
I have a suggestion to improve the competition and make it more Hunger Games-like. In the books, everyone knows that there are 24 competitors. Can the number of competitors be locked, say, a day before the submission deadline so that this can be told to competitors? (I was planning to include this in my algorithm)
In your algorithm, you can use the number of opponents, e.g. by taking the length of the list of reputations.
No, I mean as in total number of competitors in the entire competition.
I really want to partake in this competition but have no Python experience. I'm very well versed in Matlab, and I think those skills would cross over. Does anyone have a suggested tutorial or book that I could use to familiarize myself with Python?
I just saw that someone posted an answer to another similar question. This was already posted. If anyone has anything else that would be great.
That page is pretty good if you have prior programming experience, so I'd recommend giving it a try. If you have the time, try Codecademy.
How do you know which tribe you're in?!
Isn't that irrelevant? All you know about others in the same tribe/game is their reps and number.
I think that everyone is in the same tribe.
Also, can anyone direct me to a really in-depth guide to installing and running python. I'm lost here D=
I personally started from here
The rules note that to start, players will have 300(P-1) units of food. Considering the fact that there is bound to be much more than 50 teams/individuals, isn't that too little for this competition? With 61 teams, each team receives 5 food units, and nobody can hunt, rendering the competition essentially over.
Everyone gets 300×(P−1) units of food, not 300/(P−1).
Okay, wow; embarassing reading fail on my part. Thanks.
Everyone will get 300(P-1) food. Since you can lose a maximum of 3 food per hunt, and have P-1 hunts per round, no player should die before round 100. Especially since the bonus foods come into play
I'd like to have some clarification to this too. From what I understood with my high school mathematics "300(P-1)" means "300 * (number of players - 1)". So if there were 61 players, each of them would gain 300 * (61-1) = 18000 units of food. This sounds ridiculously high amount for food per player altho number of hunt choices and change in food per round rises too. I just assume I understood something wrong.
Why ridiculously high? It just means that there will be more than 100 rounds for every player, in case you loose -3*60 = -180 food per round. The big number of rounds is useful to find the best algorithm and not just a casuality.
That's correct, there will likely be many, many rounds.
So, if I don't know any programming languages, could I learn python fast enough for this? Second question, say the tribe qualifies for extra food (through the m thing), then if I don't hunt but my partner does, do we both get plus 2, or would it just be factored into who ever hunts? Like, we normally get (0/2)-2 each if no one hunts, would we still get that, or would we get (4/2)-2? Third question, do we have to decide when we write our code what we are going to do each round, or every round we enter some variable or other into our code and decide then?
Rebecca: I would say it's not impossible in principle. Your best bet is probably to find a beginner's Python 2 tutorial (Learn Python the Hard Way is my favorite) and run through that until you understand all the sample code posted here. I'd say the math is harder than the programming.
Most of this competition is primarily math, as Chad said. You can even just construct simple flowcharts which are purely logical thinking diagrams. Find someone in school who's a computer whiz, pair up with him/her for the competition and get him/her to put your logic into code.
Sounds like taking advantage of people for selfish motives. What if we don't find any "computer whizzes"?
Are there means to ensure that the "Southampton Strategy" described in the Prisoners' Dilemma wiki page is illegal? The basic idea of the strategy is to submit different Players that conspire together to ensure a specific Player wins. Is this permissible or not?
It is not allowed, but even if you'd try, you wouldn't succeed: you don't know with who you are hunting, just their reputation.
That's not quite true - the Southampton Strategy involves using a certain number of rounds to send a "signal" fellow conspiring Players so that they can identify each other with some high probability. So, yes, you can probably find out if you happen to be playing with any conspiring Players.
player_reputations
may change from round to round?player_reputation
, then it's too difficult.They shuffle the player array every round, and you don't get any information about any given partner except their reputation. This makes it very difficult if not impossible to keep track of any individual player between rounds.
If we re-sort the reputation list, will our answers correspond to the resorted list or the original?
The list of
hunt_decisions
you return will be matched up to the order ofplayer_reputations
thehost
sent you, so if you re-sort it you should keep track of which is which so you can match opponents up correctly before returning.Also regarding Chad's 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 thereputation_list
).All arguments sent to
Player
s are eitherint
s (passed by value),float
s (passed by value) or not used at all in the host (outcomes
andplayer_reputations
(both are created using a list comprehension in the function arguments to make it clear that it shouldn't be used internally))ok, thanks for clarifying; it means my github simulation is wrong. I've opened an Issue about it.
You're only returning your strategy, so the game will almost certainly assume you meant your answers to correspond with the original.
As an aside, I would hope
reputation_list
is something immutable and not an actuallist
lest someone break it. ;)Is the first round round #0, or round #1?
Never mind, I just reread the rules. It's round #1.
in the sample code, the function huntchoices takes as an argument the list playerreputations, it is explained that player_reputations is the list of floats, the reputations of all the remaining players in the game. Does this include self. And when generating the output does hunting with self influence anything?
In game rules it's mentioned you have a chance to hunt every other remaining player, so your rep will not be in the list.
i cannot understand what we have to do do we have to play game or write python ??? help please
You have to write a code to play the game for you. The code will decide wether or not you will hunt or slack. (I'm pretty sure)
Just double checking, we will get 2 bonus food every time we come to a new partner in a round?(cause we see everyone once every round) Or is it at the end of each round we get 2 bonus food?
No no no. Every round, random value m is selected in between 1 and players * (players-1). If total number of hunts (eg. sum of "h"s of every player) is equal or higher than m, every player no matter what they chose gets 2 * (players-1) food. If there were 11 players in total, each of them would get 20 food as an award.
I'm unclear about this. I believe that this is more accurately described as:
if total number of hunts(sum of 'h's of every player) is greater than or equal to m, then the tribe receives 2 * (players-1) food to be evenly distributed to each player.
I believe this is true based on "which means that on average everyone gets 2 units of food per hunt. "
Can you please clarify what happens when I decide to slack, and the other decides to hunt? If I understood correctly, this is the only case in which I can get a positive amount of food. The other player will spend 6 units of food to hunt, and I will spend only 2 because I slack. The hunt made by the other player will bring a total of 6 units of foods, which will be divided among us. So, the net changes will be -6 + (6/2) = -3 for the other player, and -2 + (6/2) = +1 for me.
Is this reasoning correct?
Yes. Also remember public goods if sum of all hunt choices is above m.
When can we submit?
I gather there is now way to know for sure how much food each (or some) of the other players have left before each round?
If I submit my code and revise it, can I submit again, overwriting my initial submission?
Yes, we'll explain that better in instructions on the form tomorrow, but yeah, the form can be updated until the submission deadline (I will make a countdown timer on that page at some point for the deadline).
What exactly is probability in regards to Page 3 (Games with mixed strategies) of the training exercises? Are the probabilities showing that player 1 has a 25% chance of playing c and playing d with a 75% chance?
As I understand, it says in the long run player one will play c 25% of the time and d 75% of the time.
If the nash equilibrium shown on training exercise 3 is -2,-1 and it states that player 2 would play C with probability 2/3, how is it possible that player 2 would play C with a higher chance? Shouldn't player 2 be playing D since -2,-1 is the nash equilibrium for this problem?
Hey ! do we need to write the same variable names as told in examples ? Or can we create our own ?
All objects and function exposed back to our host need to have the given names. Internal to your own code you are free to use whatever you want.
Are we allowed to use Python's standard library? Any modules in there that we aren't allowed to use?
From the FAQ:
When it says Scipy, does it mean the scipy stack or just the scipy library? a.k.a. Can I use pandas?
Are all players in one tribe together, or are there multiple tribes?
(This has been asked before, but has not been clearly answered by anyone from Brilliant.)
If you want to win, it is an important distinction. If we are all in one tribe, then there is at best very marginal incentive to go for the extra food goal, and none for players who think they are winning.
As of now, we are all in the same tribe. This could change later if there are incredibly too many players, in which case (from what I understand) we will only compete within our tribe, and then the winners/survivors from each tribe go on to a second round. (I could be mistaken, since I'm working from memory and too lazy to click over to the FAQ's or further down in the discussions...)
It has been answered by the staff, in the FAQ.
Thanks. I see that there are not multiple tribes in one competition.
I want to add another voice to those strongly encouraging that this be changed, for this competition or for subsequent competitions should they exists. The game would be significantly more interesting. It sounds like the competition-as-designed is relying on some players playing to survive, yet rewarding players who win. (Since the non-winner rewards are entirely subjective, they don't incentivize either strategy and must be ignored from this perspective). I can see no reason to care about m while trying to win
Does anyone know about how many people will be competing?
It will be announced in the first round itself as everyone plays together in every round (with the exception of the algorithms that have been eliminated). Behind that deadline I have no clue.
Just to be sure: The foodearnings elements in huntoutcomes() are the sum of: earned food (0,3 or 6) MINUS food needed (2 or 6) PLUS possible coorperation reward (0 or 2). correct?
No. The "cooperation reward" (or "public good") is an additional lump sum that is 2(P-1), where P is the total number of players. It is not conditional on hunting or not. It is simply a lump sum given to everyone if the threshold (total number of hunts > m) is achieved.
Are you sure? It says
but a little bit lower:
I guess the second one makes more sense, but this should be fixed in the sample code then
The amount of food you have next round is currentfood + sum(foodearnings) + publicgoodaward, where publicgoodaward is 0 if totalhunts < m and 2(P-1) if totalhunts > m.
food_earnings
is a list of integers where each item is the result for an individual hunt (each item is one of -3, -2, 0, 1). The position infood_earnings
corresponds to the position of the reputations passed into hunt_choices asplayer_reputations
.Your current food after the round/public award are calculated is the sum of all items in
food_earnings
plus your previous food, plus the public award as stated in both of the quoted strings (although the second quote doesn't explicitly mention thatfood_earnings
is a list, it doesn't say it isn't a list either, it just says that element should be "taken into account" to determine your next round starting food at that stage in execution).food_earnings
in your original comment which is not the slight "omission".I just realized it's theoretically possible to track algorithms throughout the game. Although an algorithm cannot track other algorithms precisely through the first few rounds, the precision will increase as the rounds increase. I've already written this algorithm, and it's purely based on tracking reputations and matching expected patterns to the given player pattern, so if two or more algorithms share the same reputations throughout the game, it will never precisely be able to determine which algorithm shows which reputation. (Always slacking/always hunting algorithms is an example of this category of indeterminate algorithms.)
Yes, it's possible yet not worth the risk IMO. Even after high number of rounds reps of players could "overlap" and you can't reliably connect player <-> rep. However, whole tracking thing opens up new options.
You can let your code determine how much they overlap, and if it's pretty clear that some reputation is from the same player as some earlier reputation, then you can decide to do something with it.
P1 and P2 which are different from my own algorithms. If P1 has a reputation of, say, 0.5 in round 500 and P2 has a reputation of 0.4 in round 4, and so far I've noticed that P1 generally slacks and P2 generally hunts, it should be pretty straightforward after a certain amount of rounds to discern between the two players if their reputations windup being the same. Of course, if they end up with the same reputation after a few rounds they have been playing different strategies, but an algorithm should be smart enough to detect these patterns over a few hundred rounds.
Yeah. For example, consider two playersIs the range of M calculated on the total number of players at the start of the game or the total number of living players? Same question for the awards.
living players at the start of the round
Can someone help me? I wanna know if it is possible to keep track of players.For example, I wanna know the player's hunt decisions.
I don't think it's possible to know each players choices. Instead it might be possible to estimate the numbers of hunts and slacks by comparing the reputation between adjacent rounds. This has been discussed below. E.g. consider three players at start of round t, with reputations (unsorted) Rt=[0.20 0.55 0.21]. At round t+1 you are given (randomized order) Rt+1=[0.53 0.21 0.22]. You can guess that element/position two in Rt and element one in Rt+1 belong to the same player, i.e. 0.55→0.53. For this to work the changes in reputation between two rounds must be small and overlaps shouldn't exist which would make it difficult for you to distinguish players, i.e. is it 0.20→0.21 or is it 0.20→0.22?
The formula for calculating reputation is given in the rules and might be used to estimate the number of hunts/slacks when you, more or less successfully, have tracked a player.
Thanks for the advice. But do the reputations change during a round? Does the list refresh during the round or only at the end of the round?
Hunts vs. slacks is simple to calculate. Note that hunts+slacks=total number of plays=current round number-1. As R=H+SH, hunts=reputation*(current round number-1) and slacks=current round number -1 - hunts. This, in theory, provides a mechanism to be able to track players through the game but not perfectly, since two algorithms may have the same reputation (and probably will).
To help you out and since I won't have the time to participate: First we have that reputation at start of round t is calculated as: Rt=Ht+StHt.
Let Nt and Pt be total number of hunts/games you have played and the number of players alive at start of round t, respectively. Then
Nt=Ht+St=i=1∑t−1(Pi−1)
and
Rt+1=Nt+Pt−1NtRt+ht, where 0≤ht≤Pt−1 is the number of times you choose to hunt in round t.
You can also calculate stuff like the maximum range of Rt+1 as the difference of the reputation if you become a hunter 100% of times (ht=Pt−1) minus if you become a hunter zero times (ht=0).
range(Rt+1)=Rt+1max−Rt+1min=Nt+Pt−1Pt−1.
Good luck!
Hey, can I use the import command to import the random file? import random Is this allowed, or do we need to restrict the program to just 1 file?
What happens if a program get kicked out of the competition (eg. time-out, or some irregular behaviour)? It will suddenly die (so we should also expect random deaths) or it get substituted by some fixed strategy (eg. "always hunt", "chose at random", or "pick a random player, and replicate his moves for this turn")? Or the competition restart from scratch with that program removed?
Before we run the full competition we will do a brief burn in and algorithm inspection to weed out algorithms that are completely broken, try to hack the game, or are totally error filled. "Bad strategy" will not be weeded out of course. If you pass this initial inspection, but your algorithm hangs or has a problem later in the game, you will not be kicked out. However, if there is a time out or error that prevents your algorithm from returning a properly defined set of choices in a round, then for that round you will be treated as an 'always slacker' by the host but remain in game.
I was wondering if, within a round. the choices array and the reputation array had the same order of contestants. I know the reputation array is shuffled for every round, but I was wondering if we had knowledge over the distribution of reputations or if we knew the actual reputation of the other contestant as a prior for every decision.
You know the reputation of any player before you choose to hunt/slack with them. You get a list of reputations, and you return a hunt/slack decision for each of those players, in the same order.
Hi. First time on brilliant.org. Great challenge!
However, I have observed some weird behaviour. This is assuming we allow negative food. One player gets kicked out because his food gets to 0 Now the game continues until there are only two players left. Both have 1 food. Both defect. So now they have both -1 food.
Does that mean the player that died first wins?
see the faq for the rules in case of a tie
Can we submit and then resubmit later before the deadline? Or in other words, can I decide to submit something now but improve it later if I have the time?
Yes, that is perfectly fine, we decided to allow that because we didn't want to disadvantage people who submit early (which we would like people to do so that can do more performance testing of the host and stuff like that).
From what I understood you can submit more than once, 'overwriting' the last submission.
I'm just a little confused about the food. Is it all in a big tribal pool of food, shared with everybody as resources are demanded, or does each person have 300(P-1) foods. For example in a 101 player game would you have 300,000 food units, or would the entire tribe?
Never mind, I understand the reasoning behind the number. But does P change as players die? I assume it must, because the hunts would have to change number.
No, each player is given an original amount of food dependent on the original amount of players. That's it. They then either earn food through hunts or by achieving the cooperation threshold. The value of the threshold, however, is dependent on the number of players in the round in which the threshold was achieved.
does the reputation list include your own reputation, or just everybody else's.
Everyone else's.
At the end of the round, which function gets called first: huntoutcomes or roundend?
hunt_outcomes
comes first, thenround_end
I don't have experience in Python, and I would like to take my decisions based on the last round's food_earnings. How can I do that?
You could save that list as a global list, which you can access the upcoming round. I believe the sample code shows how to do that. Does that answer your question?
Thank you, but can you give me an example of how to do that?
global
orself
in the sample code, depending on how your overall solution looks.You could have a variable
last_food_earnings
and just storefood_earnings
to that every round beyond the first.Otherwise self.lastfoodearnings will hold the address of the list, and so if the host modifies the contents of food_earnings, your list will also be updated.
Could you tell me if I'm mistaken?
food_earnings[:]
also works.Also, while
[:]
works, it's not the most readable thing. Using ipython and%timeit
, copying a list of 1000 integers takes the same amount of time with either method, so readability should probably win the tie-breaker. (actually, a bit of further testing showed with a 100000 integer list, it is slightly faster to copy a list withlist()
and with a 100 integer list, is is faster to copy a list with[:]
)and each time you get new food earnings, you type
which you can access anytime you want.
If I resort the reputation list, my huntdecisions list will be assigned to the original list right? Or the huntdecisions will be resorted just as the reputation list?
The game will assume your responses come in the same order as the reputation. So if you sort the reputations list for some reason, you need to keep track of the original order so you can return the answer properly.
Thanks, but I have no idea of how to do that
During the course of the game, is Shell (or whichever program that is going to be used) going to be restarted at any time? It's for how "deep" global variables can be defined.
Can we use Python's
itertools
module?Yes! Encouraged even, since it's often the fastest way to do things.
Can I use python 3.3, or must I stick with 2.7?
All your code needs to be compatible with Python 2.7, as that's what the actual engine runs.
Hi. How can I keep the number of total hunts and slacks till round n? I'm trying to update the number of hunts and slacks like this: thetotalnumber += len(playerreputations) But it seems to not work(?) since in each new round "thetotal_number" will be new(?)... What's the solution?! Thanks.
It may be that it is not a global variable. Make sure to call "global thetotalnumber" before using it, otherwise it will be considered a local variable, and it will be destroyed at the end of each turn, to be created anew the next one... At least that's what I think the problem is...
If you're using a class, you want
self.the_total_number
. if not, you need aglobal
declaration as Esteban pointed out.I want to make sure all my variables and numbers are divided as floats, not integers. I know adding
in the very beginning is a solution. Is it OK to do that?
Should work just fine.
Thank you!
I'm quite confused with this contest "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."
So even if you don't choose to participate in the hunt you will get the 2 bonus food?
m < people who hunt(everyone gets 2 food bonus)
if your partner dont hunt
if your partner do hunt
m > people who hunt(no one gets bonus)
if your partner dont hunt
if your partner do hunt
So, it seems that in all cases you benefit more from slacking, I feel like I'm missing something here...
It's true slacking is the best option always in short term, however this is why they added reputation to game: Others can 'starve' slackers while hunting with eachother => slackers die first. However this depends on how many (hopefully 99%) of the algorithms do this to slackers. Also award is 2 * (amountofplayers - 1), not just 2. And yes, everybody gets the award no matter what they chose.
Ok, what about the bonus food when number of hunters are greater than m? Why is this useful? I feel since everybody gets equal amount of bonus food wouldn't that be the same as no one gets the bonus food? Is this just to help slackers survive longer or something?
So I'm a newborn programmer, vulnerable and naive to everything here. I got a rough introduction to Python and feel I can write a playable code, even if it terribly fails strategy-wise. I looked at people's testing engines and am lost. How do I test my Python file using a testing thing? (ie, what buttons to click where, etc.)
Justin, my email address is on my github repo if you would like me to elaborate on the instructions that are already there.
ahhh i can't... under your profile it has a link that is a blue text "{email}", and when i click it goes to microsoft outlook where it doesn't get your email. It just has "{email}" with no blue and it is useless. Helllp someone... And I use yahoo anyways... My basic question: How to import tester script so I can test my code? I have python and stuff downloaded and working. -In case it makes a difference, I don't have a Github account. Does making one make a difference in viewing your email?
You shouldn't need to import anything. Simply run python from the base directory of the project, e.g.
python unittests.py
You can reach me at[email protected]
How exactly will the variables be updated, i.e. How will player_reputations be updated?
Also, will it be possible to obtain what your partner lastplayed by simply creating a lastplayed variable, and asking for input. Basically, how can we learn what are partner last played, because in a real life situation, we would be able to know what they last did, and then decide based on that. So how can we learn what are partner last did?
I am not sure what you mean with that first question... players' reputations update after every round (see game rules for more info on that), and during next hunting round shuffled lists of these reputations are sent to players. Player reputations list is always in randomized order so you can't directly connect certain rep and/or certain decision from last round to certain player. Best you can is to compared reputations from last round with new ones and 'connect' them.
sir can we submit a code in C++
Only python is allowed. See FAQ
why is reputation needed in hunger games????????
otherwise the best choice would be slack
Hi,
Is the deadline today end of the day, or tomorrow end of the day? (ie. by the end of the day Saturday or by the end of the day Sunday)
There's a counter on "submit code" page.
I feel like this has been asked before, but I can't find a clear answer. What is the starting reputation that is passed to each player at the first round of the game?
0
It's a boring algorithm but based on my simulations and my math/population assumptions (which could be wrong) I wouldn't be surprised if a 100% hunter (i.e. pushover) wins this thing. There are a lot of populations where a pushover is optimal.
I would be pretty surprised. I think one of the first things that people would consider is to exploit the pushovers.
It's a goofy thing, but nearly every naive strategy I could come up with (including some people have already said they submitted as their answer) overrates reputation. But I predict that despite overrating reputation, few people will go for maximizing their reputation because Pushover is so transparently exploitable.
my writeup, but the parts about the "Mole" give a picture of how surprisingly easy it is for such a strategy to be exploited by a strategy that maintains reputation by hunting with the slackers.
Analytically. I didn't post all of it inI don't think I've ever seen Pushover win in any of the dozens of simulations I've done. The only way I could see it happening is if everyone (or at least, a majority?) submitted strategies that only hunt with individuals who have a reputation of 1, and slack with everyone else.
Plus, I'm assuming the organizers won't accept Pushover, Freeloader, or Alternator, since they gave those away in their test kit. In fact, I've been assuming the organizers will include those three strategies as part of the tribe, and simply disqualify them in the (exceptionally unlikely) event that any of them get first place. That's just my guess though; I could be (and probably am) wrong!
Plus, I'm assuming the organizers won't accept Pushover, Freeloader, or Alternator, since they gave those away in their test kit. In fact, I've been assuming the organizers will include those three strategies as part of the tribe, and simply disqualify them in the (exceptionally unlikely) event that any of them get first place. That's just my guess though; I could be (and probably am) wrong!
They never stated this so I can't see this being true. It would actually be unfair if this is true in my opinion.
I'm not sure how many people are going to submit simple strategies like "fair hunter". But if there are greater than 33% fair hunters, and a large majority of the remaining population doesn't penalize you for having a high rep, than a pushover will win. This sort of population is probably unlikely but it shows how valuable it is to get people to hunt with you.
If the FairHunters have anyone to slack against (which they will if the average reputation is < 1), they'll almost certainly end up with more food than any Pushover. Only if the population is packed with MaxHunter-type strategies will Pushover stand a chance at winning.
How do I sign up for this Hunger Games competition??? My friend and I are interested in this concept and wish to enter next year!!!
Can we use C++ for this purpose?
Nope,Python only
Students have exams in August, might want to consider postponing the deadline till mid Sept (i.e. before the start of the next semester)
Totally depends on the country you're in, I'd say.
Yes I agree with Tim. The academic year in the United States starts in early September.
Hey, Just wanted to ask a question which is already answered in FAQ. Would it be okay if we use other languages to make the game, but without using none of the advanced function/perks the other languages have. Cause for people just learning programming, they wouldn't have that much knowledge about the advance features and I just guess that it would also be fair if we are allowed to write in a language we are comfortable in. Obviously you can check the code and see if it uses advanced functions and just eliminate that from the competition, cause myself am still learning c++ and it would be bad if I had to learn 2 languages at once i.e Python
They have always answered "No." to this question, but you have a good point. I remember how I was afraid of Python 'corrupting' my programming skills with Java (no need to define data types etc).
Learning two languages at once shouldn't be a real detriment. If anything, concepts from one language can help inform the other.
Dhanin: I first learned to program on C and I don't think Python would be that hard to pick up. There's a definite learning curve if you want to use more advanced stuff, but you can write Python code that basically looks like garbage-collected C if you want.
I don't think it is a matter of advanced functions/perks. I believe its a matter of being able to run everyone's submissions together. If it's not in the same language, the program they are using to run the competition won't be able to recognize your code. I could be mistaken on this, but either way, if they allow C++, then why not Java, or Fortran, or any other of the hundreds of languages out there that other people are more comfortable in.
Can anyone tell me about the various variable names for the specific ones ? Also, How to cooperate with other players in the game ?
You cooperate by hunting. What variable names are you talking about?
the list of reputations shouldn't be randomized
The game is trivial if everyone can track everyone's food.
Is it really that trivial? Seems like it breaks down to the original prisoner's dilemma and you should just use some variant of tit for tat
If we all submit the code for a "Slacky" strategy, we will all get a t-shirt from Brililant. Please click "Vote Up" to this post if you are going to submit a slacky strategy :-).
Are you sure this is true? :)
If we all play as hunters, then somebody could take advantage of this, and win by playing as the only slacky. If we all play as slackers, then we will all die at the same time, but there is no way that an hunter can beat us. We all win if we collaborate to not collaborate.
Seriously though, we'll put in some explicit rules about ties (which this would be) as someone else had a similar question.
That would end quickly. Everybody hunting every turn, however, would make sure everybody survives.
I had to give it a try :-). Anyway, we will all die quickly, but according to the rules, we will get the t-shirt anyway.