Note that there are some explanatory texts on larger screens.

plurals
  1. POSolving a simple maximization game
    text
    copied!<p>I've got a very simple question about a game I created (this is not homework): what should the following method contain to maximize payoff:</p> <pre><code>private static boolean goForBiggerResource() { return ... // I must fill this }; </code></pre> <p>Once again I stress that this is not homework: I'm trying to understand what is at work here.</p> <p>The "strategy" is trivial: there can only be two choices: true or false.</p> <p>The "game" itself is very simple:</p> <pre><code>P1 R1 R2 P2 R5 P3 R3 R4 P4 </code></pre> <ul> <li><p>there are four players (P1, P2, P3 and P4) and five resources (R1, R2, R3, R4 all worth 1 and R5, worth 2)</p></li> <li><p>each player has exactly two options: either go for a resource close to its starting location that gives 1 and that the player is sure to get (no other player can get to that resource first) <em>OR</em> the player can try to go for a resource that is worth 2... But other players may go for it too.</p></li> <li><p>if two or more players go for the bigger resource (the one worth 2), then they'll arrive at the bigger resource at the same time and only one player, at random, will get it and the other player(s) going for that resource will get 0 (they cannot go back to a resource worth 1).</p></li> <li><p>each player play the same strategy (the one defined in the method <em>goForBiggerResource</em>())</p></li> <li><p>players cannot "talk" to each other to agree on a strategy</p></li> <li><p>the game is run 1 million times </p></li> </ul> <p>So basically I want to fill the method <em>goForBiggerResource()</em>, which returns either true or false, in a way to maximize the payoff.</p> <p>Here's the code allowing to test the solution:</p> <pre><code>private static final int NB_PLAYERS = 4; private static final int NB_ITERATIONS = 1000000; public static void main(String[] args) { double totalProfit = 0.0d; for (int i = 0; i &lt; NB_ITERATIONS; i++) { int nbGoingForExpensive = 0; for (int j = 0; j &lt; NB_PLAYERS; j++) { if ( goForBiggerResource() ) { nbGoingForExpensive++; } else { totalProfit++; } } totalProfit += nbGoingForExpensive &gt; 0 ? 2 : 0; } double payoff = totalProfit / (NB_ITERATIONS * NB_PLAYERS); System.out.println( "Payoff per player: " + payoff ); } </code></pre> <p>For example if I suggest the following solution:</p> <pre><code>private static boolean goForBiggerResource() { return true; }; </code></pre> <p>Then all four players will go for the bigger resource. Only one of them will get it, at random. Over one million iteration the average payoff per player will be 2/4 which gives 0.5 and the program shall output:</p> <p><em>Payoff per player: 0.5</em></p> <p>My question is very simple: what should go into the method <em>goForBiggerResource()</em> (which returns either true or false) to maximize the average payoff and why?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload