Slashdot Mirror


A Rock Paper Scissors Brainteaser

New submitter arsheive (609065) writes with a link to this interesting RPS brainteaser: "How do you play against an opponent who _must_ throw Rock 50% of the time, and how much would you be willing to pay to play against them?"

1 of 167 comments (clear)

  1. Re:Simple.... Odds are even by ShanghaiBill · · Score: 5, Insightful

    The Nash Equilibrium is for you to play paper 2/3rds of the time, and rock 1/3rd. His best counter strategy is to play rock 50% (he cannot go lower) and scissors 50%. He cannot do better. If you deviate from 2/3 paper and 1/3 rock, he can adjust his strategy to do better. With the optimal strategy, you will win 1/2, lose 1/3, and tie 1/6.

    Here is my search for the Nash Equilibrium:

    #include

    struct rps {
        double rock;
        double paper;
        double scissors;
    };

    static double
    eval(struct rps *a, struct rps *b)
    {
        return
            (a->rock * (b->scissors - b->paper)) +
            (a->paper * (b->rock - b->scissors)) +
            (a->scissors * (b->paper - b->rock));
    }

    int
    main(void)
    {
        struct rps you;
        struct rps him;

        him.rock = 0.5;
        double worst_best_eval_for_him = 1.0;
        double best_rock_for_you = 0;
        double best_paper_for_you = 0;
        double worst_best_paper_for_him = 0;
        double dx = 0.001;
        for (you.rock = 0; you.rock best_eval_for_him) {
                        best_eval_for_him = p;
                        best_paper_for_him = him.paper;
                    }
                }
                if (worst_best_eval_for_him > best_eval_for_him) {
                    worst_best_eval_for_him = best_eval_for_him;
                    best_rock_for_you = you.rock;
                    best_paper_for_you = you.paper;
                    worst_best_paper_for_him = best_paper_for_him;
                }
            }
        }
        printf("worst_best_eval_for_him = %f\n", worst_best_eval_for_him);
        printf("best_rock_for_you = %f\n", best_rock_for_you);
        printf("best_paper_for_you = %f\n", best_paper_for_you);
        printf("worst_best_paper_for_him = %f\n", worst_best_paper_for_him);
        return 0;
    }