Robotypo Platform: Drunkard

It's in the bar. Two guys play the game against each other. They wave fist, then yell a number, and raise some fingers at the same time (just like the Rock-paper-scissors game). He who yells the correct sum of the total fingers wins. The loser drinks the cup. Write a robot to calculate the finger and guess the sum. Make your opponent drunnnk!


Programming language: Java
Rating rule: Elo rating


Details
  • The match: The match between two drunkards (robots) has 1000 rounds.
  • What the robot does: Before each round, the strategy() method of each robot is called. In this method, the robot should set the finger count (the fingers member variable), and guess the total sum (set the sum member variable).
  • The round: In each round, the finger count from the two drunkards are added, as the actual sum. The drunkard who makes the correct guess of the sum wins the round, and gain 1 score. If no one guesses correctly, or both drunkards guess correctly, it's a draw. In this case no one gains score. But one exception is the Full Hand Rule.
  • The Full Hand rule: when both sides guess of the sum correctly, the drunkard who raises 5 fingers wins the round.
  • End of game: After all rounds are passed, the drunkard who has more score wins.

Before each round, the strategy() method of each robot is called. When setting the strategy, a robot never knows for sure what the opponent's strategy is. However you can know opponent's actions in previous rounds. It is up to you to analyze opponent's strategy, and adjust yours.



Manage your robots in My Robots, or read more details. See others in Top Robotypo.



Example Robot

Here's what a simple Drunkard robot looks like. The actual logic consists of only 2 lines:

public class DemoDrunkard extends Drunkard {

 

    // Member variables can be created to benefit your strategy

   

    /**

     * Raises our fingers and guess the total sum.

     * This method is called before each round.

     */

    public void strategy() {

        //First we need to set the number of fingers we raise.

        //There are only 5 fingers per human hand. So the finger count

        //must be 0, 1, 2, 3, 4, or 5.    

        fingers = 3;    //Here we always raise 3 fingers 

 

        //"sum" is the total finger count (sum of fingers from both drunkards). It is a number "we say".

        //At the end of this round, he who guessed the correct sum

        //wins (if opponent guesses incorrectly)

        sum = 3 + random.nextInt(6);   //Opponent may raise 0 to 5 fingers. Let's make a random guess.

 

        //The following member variables can be used, too:

        //    prevOpponentFingers, prevOpponentSum, prevResult, round.

        // You can also create new class member variables. Refer to help for details.

    }

}