Robotypo Platform: Fruit Day

It's harvest festival. Peasants are holding a Fruit Day to celebrate the fruitful year. 3 peasants form a team, and two teams throw apples and tomatoes at each other. They can also hide behind baskets to dodge attacks. Write a program to guide your team.


Programming language: Java
Rating rule: Elo rating


Basic Rules
  • The team: The match consists of two teams (one robot controls one team). Each team has 3 peasants. Each peasant has 100 HP.
  • Action: The match consists of 1000 rounds. In each round, each peasant chooses one and only one action. The action can be either HIT or HIDE.
  • HIT: Choose a peasant (0, 1, or 2) in the opponent team to hit. If a peasant chooses to hit, then others can hit him in this round, too. The HIT action is assured to hit the target if it does not hide.
  • HIDE: If a peasant chooses to hide, then others can not hit him in this round, and he can not hit others, too.
  • Out-of-play: Each time a peasant is hit, its HP is reduced by one. If the HP decreases to 0, then the peasant can not throw fruit any more. It is considered as out-of-play.
  • Coward: If a peasant hides more than 3 rounds continuously, it is called coward and it is out-of-play.
  • End of game: If all peasants in a team are out-of-play, the game ends and the opponent team wins. If there are too many rounds passed, the game ends, too. In this case, the winner is the team which has more total HP.

Before each round, the strategy() method of each robot is called. In this method, your robot needs to set actions for each peasant in your team. When setting the strategy, a robot never knows for sure what the opponent's strategy is. So it is up to you to analysis opponent's strategy, and adjust yours. In the round, hit or miss is calculated, and member variables (e.g. HP) are updated to reflect the changes.


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


Example Robot

public class MyFirstRobot extends Fruitday {

 

    //This is the method called before each round.

    public void strategy() {

 

        for (int i = 0; i < 3; i++) {      //For each peasant in our team,

 

            Peasant p = myTeam[i];

            p.action = random.nextInt(3);  //Hit a random opponent peasant.

 

            //You can also tell peasant to hide, like this:

            //p.action = HIDE;

 

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

            //    Peasant[] opponentTeam, int round.

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

        }

    }

}