Forgot your password?
typodupeerror
Math Stats Games Science

A Rock Paper Scissors Brainteaser 167

Posted by timothy
from the always-bet-on-spock dept.
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?"
This discussion has been archived. No new comments can be posted.

A Rock Paper Scissors Brainteaser

Comments Filter:
  • by Anonymous Coward on Saturday April 05, 2014 @01:01PM (#46670499)

    Expect them to play scissors a lot to beat your paper. Play rock as often as they play scissors.

  • put a spin on it (Score:4, Interesting)

    by ihtoit (3393327) on Saturday April 05, 2014 @01:09PM (#46670575)

    Rock, paper, scissors, lizard, Spock!

    Scissors cut paper
    Paper covers rock
    Rock crushes lizard
    Lizard poisons Spock
    Spock smashes scissors
    Scissors decapitate lizard
    Lizard eats paper
    Paper disproves Spock
    Spock vaporizes rock
    Rock crushes scissors

  • by NeuroBoy (82993) on Saturday April 05, 2014 @01:31PM (#46670765)

    I've been having students in my introductory programming courses work on this class of problem for a few years.. They all seem to really enjoy it. I code up bots to play RPS with certain biases just like the OP and they have to program a single player that identifies the bias in an opponent and adjusts its play to give it an advantage. They all routinely can generate solutions that perform far better than random against predictable, dumb bots, but things get very interesting when I throw the students' bots against each other in a throwdown tournament. :)

  • by ShanghaiBill (739463) on Saturday April 05, 2014 @02:56PM (#46671323)

    Sorry, but Slashdot mangled that code badly because of the angle brackets.

    Let me try again:

    #include <stdio.h>

    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 < 1.0; you.rock += dx) {
            for (you.paper= 0; (you.paper + you.rock) < 1.0; you.paper+= dx) {
                you.scissors = 1.0 - you.rock - you.paper;
                double best_paper_for_him = 0.0;
                double best_eval_for_him = -1.0;
                for (him.paper = 0; him.paper < 0.5; him.paper += dx) {
                    him.scissors = 1.0 - him.rock - him.paper;
                    double p = eval(&him, &you);
                    if (p > 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;
    }

Help! I'm trapped in a PDP 11/70!

Working...