15
\$\begingroup\$

Updated Results

Introduction

To celebrate Monster Hunter 4 Ultimate launch on new 3DS (February 13th), here's a King of the Hill themed on this game.

You are a novice hunter, who'll take part in a tournament consisting of 5 consecutives hunts. At the end of these hunts, hunters will be ranked depending on the damage they dealt to monsters and of course wether they slayed it or have been vanquished by it. Also, as a novice, you'll have to stick to the weapon you choose until you are more experienced.

Lexicon

ATK : Attack
DEF : Defense
HP  : Health Points
NRG : Energy
GRD : Guard
SPD : Speed
SHP : Sharpness
AGR : Aggressivity
POT : Potion
RAT : Ration
WHE : Whetstone

Principle

Hunters can choose among a variety of 4 weapons :

              |   Id   |  ATK  |  GRD  |  SPD  |
------------------------------------------------
Great Sword   |   GS   |   7   |   2   |   2   |
Dual Blade    |   DB   |   3   |   0   |   7   |
Lance         |   LA   |   5   |   4   |   3   |
Hammer        |   HA   |   9   |   0   |   1   |

The 5 monsters to hunt are :

              |   HP   |  ATK  |  DEF  |
----------------------------------------
Yian Kut-ku   |  1500  |   5   |   4   |
Rathian       |  1800  |   7   |   4   |
Rathalos      |  1800  |   4   |   7   |
Tigrex        |  2000  |   8   |   6   |
Fatalis       |  2500  |  11   |   7   |

When the game begins, you have to choose a weapon. Then, for each of the 5 hunts, you'll be split among teams of 4 players and you'll start hunting.

Each hunter basic stats are :

              |   HP  |  NRG  |  DEF  |  SHP  |  AGR  |
-------------------------------------------------------
Hunter        |  100  |  100  |   5   |   4   |   0   |

Stats can't go beyond their initial values (i.e. taking a potion with 50HP only restores your health up to 100HP).

Each hunter starts with :

              |  POT  |  RAT  |  WHE  |
---------------------------------------
Hunter Items  |   5   |   5   |   5   |

The controller provides you with input via command arguments, your program has to output via stdout.

Syntax

Output (preparation)
Before the game starts, the controller invokes you submission without arguments. This means you have to choose one of the 4 weapon by outputing its Id. You'll keep this weapon till the end of the game.

You need to output : WeaponID

For example : GS.

Input
Each time your program is called, it will receive arguments in this format (newlines not part of the input an only used for formatting):

Round;YourPlayerId;Monster_ATK;Monster_DEF;Monster_HP;Monster_TargetId;Monster_NextMoveId;
PlayerId_WeaponId_ATK_DEF_HP_NRG_GRD_SPD_SHP_AGR_POT_RAT_WHE_CurrentCombo;
PlayerId_WeaponId_ATK_DEF_HP_NRG_GRD_SPD_SHP_AGR_POT_RAT_WHE_CurrentCombo;
PlayerId_WeaponId_ATK_DEF_HP_NRG_GRD_SPD_SHP_AGR_POT_RAT_WHE_CurrentCombo;
PlayerId_WeaponId_ATK_DEF_HP_NRG_GRD_SPD_SHP_AGR_POT_RAT_WHE_CurrentCombo

Example input

3;3;5;5;1164;2;S;
0_LA_5_5_75_45_4_3_2_55_5_5_5_AA;
1_HA_9_5_75_100_0_1_3_321_5_5_5_N;
2_GS_7_5_75_35_2_2_2_59_5_5_5_BB;
3_DB_3_5_75_78_0_7_2_0_5_5_5_AB

Here, you see it is the 3rd minute (starts at 1) and you are player 3. You are carrying Dual Blades, you have 3 ATK, 5 DEF, 75 HP, 78 NRG, 0 GRD, 7 SPD, 2 SHP, 5 POT, 5 RAT, 5 WHE and your current combo is A->B.

Output

See gameplay.

Gameplay

Teams of 4 hunters are made randomly at the start of each hunt. If there are not enough hunters to make teams, the game will automatically add 1 or more of the 4 "helper" (Felyne, Melynx, Palico or Koneko) choosen randomly to reach desired numbers.

Each hunt lasts 50 minutes, and you can take 1 action per minute (i.e. 50 actions per hunt). For each of these 50 minutes, you'll need to output a letter corresponding to the action you'll take (see actions).

Hunters go first (in a random order choosen at the beginning), then the monster executes its action (which was provided as Monster_NextMoveId). So each minute goes like this : Hunter 1 > Hunter 2 > Hunter 3 > Hunter 4 > Monster > Next minute...

On the first minute, the monster will always use O (see actions). Each turn after its action, the monster will choose its next target by selecting the hunter with the highest AGR value. AGR decreases by 30 per minute.

If the monster or all hunters are killed, the hunt stops. The hunters are revived after each hunts, and their stats, items, combos and actions are reset to their default values.

Hunters' actions

  • A : Attack A [Requires NRG]
  • B : Attack B [Requires NRG]
  • C : Attack C [Requires NRG]
  • G : Guard [Requires 15 NRG. Can only be used if the weapon has GRD > 0. Activates GRD stat in damage formula for next turn.]
  • D : Dodge [Requires 30 NRG. Completely dodge damage for next turn.]
  • W : Wait [Restores 30 NRG. Does nothing else.]
  • T : Taunt [Restores 80 NRG. Increases AGR by 300.]
  • P : Potion [Requires 1 POT. Restores 90 HP. Reduces DEF by 2 for next turn.]
  • R : Ration [Requires 1 RAT. Restores 30 HP AND 50 NRG. Reduces DEF by 2 for next turn.]
  • S : Sharpen [Requires 1 WHE. Restores SHP to 4. Reduces DEF by 2 for next turn.]

Monsters' actions

Monsters choose their action randomly.

  • O : Observe (5% chance) [Does nothing.]
  • A : Attack (40% chance) [Attacks target (defined in Monster_TargetId).]
  • R : Roar (10% chance) [Stuns everyone. Hunters do nothing next turn.]
  • F : Fly (10% chance) [Completely dodge every attack next turn.]
  • C : Charge (15% chance) [Attacks target (defined in Monster_TargetId). Completely dodge every attack next turn.]
  • S : Spin (20% chance) [Attacks every hunter.]

Attacks & Combos

Each weapon can be used to launch 3 differents attacks : A, B and C.

Each attacks requires and consumes NRG according to this formula : energy = floor(100 / (SPD + 2))

Damages are calculated with this formula : damage = ATK * (10 + SHP - DEF [- GRD]). GRD is only applied if the hunter is currently guarding (see actions). When a hunter is using an item (see actions), his DEF is reduced by 2. Each hit on a monster reduces SHP by 1 till the minimum of 1. Monsters have a SHP of 0. Each damage inflicted to a monster increases AGR by the same value.

If you manage to chain attack to create a specific combo, your damage will be multiplicated by the corresponding bonus. Any action other than an attack reset your current combo, and combo with reset = 1 will also reset it.

              |   Combo                    | Bonus | Reset |
------------------------------------------------------------
Great Sword   | B -> B -> A                |   3   |   1   |
Great Sword   | B -> B -> B -> C           |   4   |   1   |
------------------------------------------------------------
Dual Blade    | C -> C                     |   2   |   1   |
Dual Blade    | A -> B -> A -> B           |   3   |   0   |
Dual Blade    | A -> B -> A -> B -> A      |   4   |   0   |
Dual Blade    | A -> B -> A -> B -> A -> C |   5   |   1   |
------------------------------------------------------------
Lance         | B -> B -> B                |   3   |   1   |
Lance         | A -> A -> A                |   2   |   0   |
Lance         | A -> A -> A -> C           |   4   |   1   |
------------------------------------------------------------
Hammer        | B -> B -> A                |   2   |   1   |
Hammer        | C -> C -> A                |   2   |   1   |

Rules

  • Writing to files is allowed. Please write to "yoursubmissionname.txt", the folder will be emptied before a game starts. Other external resources are disallowed.
  • Your submission has 1 second to respond.
  • Provide commands to compile and run your submissions.

Scoring & Winning

You get :

  • +1000 points for surviving a successful hunt (monster dead).
  • +0 points for surviving a unsuccessful hunt (monster alive).
  • -1000 points for passing away (hunter dead) no matter of the result of the hunt.
  • +1 point per damage dealt to the monster

Winner is the one with the highest score after 5 hunts.

Controller

You can find the controller on github. It also contains 4 samplebots, written in Java. Open it in Eclipse, place the compiled bots in the root folder and add a class to the control program (just like the samplebots).

Results

Average of 10 games :

1. Lancer: 5495
2. Felyne: 4786
3. Melynx: 4190
4. RedViper: 3886
5. Koneko: 3639
6. TheKingsJester: 3100
7. RoranStronghammer: 3046
8. WeaselWill: 2849

Complete logs of 1 game : http://pastebin.com/bfR5ZiMJ
Results of 10 games : http://pastebin.com/YWFf6qT7

\$\endgroup\$
  • 1
    \$\begingroup\$ Markdown pro-tip: you can force a single line break by terminating a line with two space. No need for <br>. (Related HTML5 pro-tip: there is no such thing as a self-closing tag. <br/> is only permitted for legacy reasons and is semantically equivalent to <br>.) \$\endgroup\$ – Martin Ender Feb 25 '15 at 16:07
  • \$\begingroup\$ Can HP and NRG go above 100? \$\endgroup\$ – captncraig Feb 25 '15 at 16:52
  • 1
    \$\begingroup\$ What does "stick to de weapon you choose until you are more experienced" mean? can the player change weapon at each encounter? are there going to be "better" weapons later? \$\endgroup\$ – rorlork Feb 25 '15 at 16:53
  • \$\begingroup\$ Is the first minute 0 or 1? \$\endgroup\$ – captncraig Feb 25 '15 at 16:58
  • 1
    \$\begingroup\$ @Geobits Yes, I upgraded my game launcher so that I can start as many games as I want to get final results. I'm thinking of 100 or 1000 games for the final results (10 games take approximately 15 minutes on my computer). \$\endgroup\$ – Thrax Mar 4 '15 at 15:24
4
\$\begingroup\$

Lancer

A disciplined warrior who employs a defensive fighting style

/*jshint node:true */
'use strict';
var fs = require('fs');

var dataFile = 'lancer.txt';

function getData(callback) {
  fs.readFile(dataFile, 'utf8', function(err, contents) {
    var data = {};

    if(!err) {
      data = JSON.parse(contents);
    }

    callback(data);
  });
}

function saveData(data, callback) {
  fs.writeFile(dataFile, JSON.stringify(data), callback);
}

function parseArgs(args){
  var gameState = {
    monster: {},
    hunters: [],
    otherHunters: []
  };

  var argArray = args.split(';');

  gameState.round = +argArray.shift();
  var myId = +argArray.shift();

  gameState.monster.attack = +argArray.shift();
  gameState.monster.defense = +argArray.shift();
  gameState.monster.hp = +argArray.shift();
  var monsterTargetId = +argArray.shift();
  gameState.monster.nextMove = argArray.shift();
  gameState.monster.guard = 0;
  gameState.monster.sharpness = 0;

  for(var index = 0; index < argArray.length; index++) {
    var hunterArgs = argArray[index].split('_');
    var hunterId = +hunterArgs.shift();
    var hunter = {};
    hunter.weapon = hunterArgs.shift();
    hunter.attack = +hunterArgs.shift();
    hunter.defense = +hunterArgs.shift();
    hunter.hp = +hunterArgs.shift();
    hunter.energy = +hunterArgs.shift();
    hunter.guard = +hunterArgs.shift();
    hunter.speed = +hunterArgs.shift();
    hunter.sharpness = +hunterArgs.shift();
    hunter.aggro = +hunterArgs.shift();
    hunter.potions = +hunterArgs.shift();
    hunter.rations = +hunterArgs.shift();
    hunter.whetstones = +hunterArgs.shift();
    hunter.combo = hunterArgs.shift().split('');

    gameState.hunters.push(hunter);

    if(myId === hunterId) {
      gameState.me = hunter;
    }
    else {
      gameState.otherHunters.push(hunter);
    }

    if(monsterTargetId === hunterId) {
      gameState.monster.target = hunter;
    }
  }

  return gameState;
}

function getAttackEnergy(hunter) {
  return Math.floor(100 / (hunter.speed + 2));
}

function getDamage(attacker, defender, useGuard) {
  var guard = useGuard ? defender.guard : 0;

  return attacker.attack * (10 + attacker.sharpness - defender.defense - guard);
}

function isAttackingMe(gameState) {
  var nextMove = gameState.monster.nextMove;
  return nextMove === 'S' || (gameState.monster.target === gameState.me && (nextMove === 'A' || nextMove === 'C'));
}

function isSafeToTaunt(gameState) {
  var maxAggro = Math.max.apply(null, gameState.otherHunters.map(function(hunter){return hunter.aggro;}));
  return gameState.me.aggro + 300 < maxAggro;
}

function getAction(gameState) {
  var damage = getDamage(gameState.me, gameState.monster);
  if(gameState.me.combo.length === 2) {
    damage *= 3;
  }

  if(damage >= gameState.monster.hp && !gameState.monster.isImmune && gameState.me.energy >= getAttackEnergy(gameState.me)) {
    return 'B';
  }

  var monsterDamage = getDamage(gameState.monster, gameState.me);
  var attackingMe = isAttackingMe(gameState);

  if(monsterDamage > gameState.me.hp) {
    if(attackingMe) {
      if(gameState.me.energy >= 30) {
        return 'D';
      }

      if(monsterDamage < getDamage(gameState.monster, gameState.me, true) && gameState.me.energy >= 15) {
        return 'G';
      }      
    }

    if(gameState.me.potions > 0) {
      return 'P';
    }

    if(gameState.me.rations > 0) {
      return 'R';
    }
  }

  if(attackingMe && gameState.me.energy >= 15) {
    return 'G';
  }

  if(gameState.me.sharpness <= 1 && gameState.me.whetstones > 0 && !attackingMe) {
    return 'S';
  }

  if(gameState.me.energy >= getAttackEnergy(gameState.me) * Math.min((3 - gameState.me.combo.length), 1) && (gameState.me.combo.length < 2 || !gameState.monster.isImmune)) {
    return 'B';
  }

  if(gameState.me.energy <= 20 && isSafeToTaunt(gameState)) {
    return 'T';
  }

  if(gameState.me.rations > 0 && gameState.me.hp <= 70 && gameState.me.energy <= 50 && !attackingMe) {
    return 'R';
  }

  return 'W';
}

function startGame() {
  console.log('LA');
}

if(process.argv.length <= 2) {
  startGame();
}
else {
  var gameState = parseArgs(process.argv[2]);
  getData(function(data) {
    if(data.monsterLastAttack === 'F' || data.monsterLastAttack === 'C') {
      gameState.monster.isImmune = true;
    }
    data.monsterLastAttack = gameState.monster.nextMove;

    saveData(data, function() {
      console.log(getAction(gameState));
    });
  });
}
/*jshint node:true */
'use strict';
var fs = require('fs');

var dataFile = 'lancer.txt';

function getData(callback) {
  fs.readFile(dataFile, 'utf8', function(err, contents) {
    var data = {};

    if(!err) {
      data = JSON.parse(contents);
    }

    callback(data);
  });
}

function saveData(data, callback) {
  fs.writeFile(dataFile, JSON.stringify(data), callback);
}

function parseArgs(args){
  var gameState = {
    monster: {},
    hunters: [],
    otherHunters: []
  };

  var argArray = args.split(';');

  gameState.round = +argArray.shift();
  var myId = +argArray.shift();

  gameState.monster.attack = +argArray.shift();
  gameState.monster.defense = +argArray.shift();
  gameState.monster.hp = +argArray.shift();
  var monsterTargetId = +argArray.shift();
  gameState.monster.nextMove = argArray.shift();
  gameState.monster.guard = 0;
  gameState.monster.sharpness = 0;

  for(var index = 0; index < argArray.length; index++) {
    var hunterArgs = argArray[index].split('_');
    var hunterId = +hunterArgs.shift();
    var hunter = {};
    hunter.weapon = hunterArgs.shift();
    hunter.attack = +hunterArgs.shift();
    hunter.defense = +hunterArgs.shift();
    hunter.hp = +hunterArgs.shift();
    hunter.energy = +hunterArgs.shift();
    hunter.guard = +hunterArgs.shift();
    hunter.speed = +hunterArgs.shift();
    hunter.sharpness = +hunterArgs.shift();
    hunter.aggro = +hunterArgs.shift();
    hunter.potions = +hunterArgs.shift();
    hunter.rations = +hunterArgs.shift();
    hunter.whetstones = +hunterArgs.shift();
    hunter.combo = hunterArgs.shift().split('');

    gameState.hunters.push(hunter);

    if(myId === hunterId) {
      gameState.me = hunter;
    }
    else {
      gameState.otherHunters.push(hunter);
    }

    if(monsterTargetId === hunterId) {
      gameState.monster.target = hunter;
    }
  }

  return gameState;
}

function getAttackEnergy(hunter) {
  return Math.floor(100 / (hunter.speed + 2));
}

function getDamage(attacker, defender, useGuard) {
  var guard = useGuard ? defender.guard : 0;

  return attacker.attack * (10 + attacker.sharpness - defender.defense - guard);
}

function isAttackingMe(gameState) {
  var nextMove = gameState.monster.nextMove;
  return nextMove === 'S' || (gameState.monster.target === gameState.me && (nextMove === 'A' || nextMove === 'C'));
}

function isSafeToTaunt(gameState) {
  var maxAggro = Math.max.apply(null, gameState.otherHunters.map(function(hunter){return hunter.aggro;}));
  return gameState.me.aggro + 300 < maxAggro;
}

function getAction(gameState) {
  var damage = getDamage(gameState.me, gameState.monster);
  if(gameState.me.combo.length === 2) {
    damage *= 3;
  }

  if(damage >= gameState.monster.hp && !gameState.monster.isImmune && gameState.me.energy >= getAttackEnergy(gameState.me)) {
    return 'B';
  }

  var monsterDamage = getDamage(gameState.monster, gameState.me);
  var attackingMe = isAttackingMe(gameState);

  if(monsterDamage > gameState.me.hp) {
    if(attackingMe) {
      if(gameState.me.energy >= 30) {
        return 'D';
      }

      if(monsterDamage < getDamage(gameState.monster, gameState.me, true) && gameState.me.energy >= 15) {
        return 'G';
      }      
    }

    if(gameState.me.potions > 0) {
      return 'P';
    }

    if(gameState.me.rations > 0) {
      return 'R';
    }
  }

  if(attackingMe && gameState.me.energy >= 15) {
    return 'G';
  }

  if(gameState.me.sharpness <= 1 && gameState.me.whetstones > 0 && !attackingMe) {
    return 'S';
  }

  if(gameState.me.energy >= getAttackEnergy(gameState.me) * Math.min((3 - gameState.me.combo.length), 1) && (gameState.me.combo.length < 2 || !gameState.monster.isImmune)) {
    return 'B';
  }

  if(gameState.me.energy <= 20 && isSafeToTaunt(gameState)) {
    return 'T';
  }

  if(gameState.me.rations > 0 && gameState.me.hp <= 70 && gameState.me.energy <= 50 && !attackingMe) {
    return 'R';
  }

  return 'W';
}

function startGame() {
  console.log('LA');
}

if(process.argv.length <= 2) {
  startGame();
}
else {
  var gameState = parseArgs(process.argv[2]);
  getData(function(data) {
    if(data.monsterLastAttack === 'F' || data.monsterLastAttack === 'C') {
      gameState.monster.isImmune = true;
    }
    data.monsterLastAttack = gameState.monster.nextMove;

    saveData(data, function() {
      console.log(getAction(gameState));
    });
  });
}

Save as lancer.js, run with node lancer

\$\endgroup\$
  • 1
    \$\begingroup\$ There seems to be quite a bit of variety in this challenge depending on how the RNG causes the monster to behave and, more importantly, the team makeup. I've seen this entry come in anywhere from a commanding lead to dead last. Keeps things interesting. \$\endgroup\$ – Spencer Mar 2 '15 at 21:01
  • \$\begingroup\$ Lancer did pretty well in the test games! First in 3 of 5 games. \$\endgroup\$ – Thrax Mar 3 '15 at 16:04
8
\$\begingroup\$

Java, Roran Stronghammer

He wields the hammer of death.

import java.util.ArrayList;
import java.util.List;


public class RoranStronghammer {

    int round;
    int playerID;
    Hunter thisHunter;
    List<Hunter> hunters = new ArrayList<>();
    List<Hunter> otherHunters = new ArrayList<>();
    Monster monster;
    boolean canTauntSafely;

    public static void main(String[] args){
        if (args.length == 0) {
            System.out.println("HA");//ha!
        } else {
            System.out.println(new RoranStronghammer(args).hunt());
        }
    }

    private String hunt() {

        int requiredEnergy = 100 / (thisHunter.getSpeed() + 2);

        if (requiredEnergy > thisHunter.getEnergy()){
            if (canTauntSafely){
                return "T";
            }
            if (thisHunter.getRations() > 0){
                return "R";
            }
            return "T";
        }


        int damage = thisHunter.getAtk() * (10 + thisHunter.getSharpness() - monster.getDef());
        int monsterDamage = monster.getAtk() * (10 - thisHunter.getDef());

        String currentCombo = thisHunter.getAttacks();

        if (damage > monster.getHp()){//Kill monster if possible.
            return "B";
        }

        if (currentCombo.length() >= 2 && damage * 2 > monster.getHp()){//Kill monster if possible.
            return "A";
        }

        if (monsterDamage > thisHunter.getHp()){
            if (thisHunter.getPotions() > 0 && thisHunter.getHp() <= 10){
                return "P";
            }
            if (thisHunter.getEnergy() <= 50 && thisHunter.getRations() > 0){
                return "R";
            }
            if (thisHunter.getPotions() > 0){
                return "P";
            }
        }

        if (currentCombo.length() >= 2){
            return "A";                    //Do critical hit
        }

        if (currentCombo.length() == 0){
            if (thisHunter.getEnergy() < requiredEnergy * 3) {
                if (canTauntSafely){
                    return "T";
                }
                if (thisHunter.getRations() > 0) {
                    return "R";
                }
                return "T";
            }
            if (thisHunter.getSharpness() < 4){
                return "S";
            }
        }
        if (currentCombo.length() == 1){
            if (thisHunter.getEnergy() < requiredEnergy * 2) {
                if (canTauntSafely){
                    return "T";
                }
                if (thisHunter.getRations() > 0) {
                    return "R";
                }
                return "T";
            }
            if (thisHunter.getSharpness() < 3){
                return "S";
            }
        }
        return "B";                   //Attack constantly.

    }

    public RoranStronghammer(String[] args) {

        args = args[0].split(";");

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);
        monster = new Monster(args[2]+";"+args[3]+";"+args[4]+";"+args[5]+";"+args[6]);


        for (int i = 7; i < args.length; i++){
            hunters.add(new Hunter(args[i]));
        }

        int mostAggressiveness = 0;
        int myAggressiveness = 0;

        for (Hunter hunter : hunters) {
            if (hunter.isMe()){
                thisHunter = hunter;
                myAggressiveness = hunter.getAggro();
            } else {
                otherHunters.add(hunter);
                mostAggressiveness = Math.max(mostAggressiveness, hunter.getAggro());
            }
        }

        canTauntSafely = myAggressiveness + 300 < mostAggressiveness;
    }

    private class Monster {

        int atk;
        int def;
        int hp;
        int targetId;
        String nextMove;

        public Monster(String string) {
            String[] args = string.split(";");
            atk = Integer.parseInt(args[0]);
            def = Integer.parseInt(args[1]);
            hp = Integer.parseInt(args[2]);
            targetId = Integer.parseInt(args[3]);
            nextMove = args[4];
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getTargetId() {
            return targetId;
        }

        public void setTargetId(int targetId) {
            this.targetId = targetId;
        }

        public String getNextMove() {
            return nextMove;
        }

        public void setNextMove(String nextMove) {
            this.nextMove = nextMove;
        }
    }

    private class Hunter {
        int hunterID;
        String weapon;
        int atk;
        int def;
        int hp;
        int energy;
        int guard;
        int speed;
        int sharpness;
        int aggro;
        int potions;
        int rations;
        int whetstones;
        String attacks;

        public Hunter(String string) {
            String[] args = string.split("_");
            hunterID = Integer.parseInt(args[0]);
            weapon = args[1];
            atk = Integer.parseInt(args[2]);
            def = Integer.parseInt(args[3]);
            hp = Integer.parseInt(args[4]);
            energy = Integer.parseInt(args[5]);
            guard = Integer.parseInt(args[6]);
            speed = Integer.parseInt(args[7]);
            sharpness = Integer.parseInt(args[8]);
            aggro = Integer.parseInt(args[9]);
            potions = Integer.parseInt(args[10]);
            rations = Integer.parseInt(args[11]);
            whetstones = Integer.parseInt(args[12]);
            attacks = args[13];
        }

        public int getHunterID() {
            return hunterID;
        }

        public void setHunterID(int hunterID) {
            this.hunterID = hunterID;
        }

        public String getWeapon() {
            return weapon;
        }

        public void setWeapon(String weapon) {
            this.weapon = weapon;
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getEnergy() {
            return energy;
        }

        public void setEnergy(int energy) {
            this.energy = energy;
        }

        public int getGuard() {
            return guard;
        }

        public void setGuard(int guard) {
            this.guard = guard;
        }

        public int getSpeed() {
            return speed;
        }

        public void setSpeed(int speed) {
            this.speed = speed;
        }

        public int getSharpness() {
            return sharpness;
        }

        public void setSharpness(int sharpness) {
            this.sharpness = sharpness;
        }

        public int getAggro() {
            return aggro;
        }

        public void setAggro(int aggro) {
            this.aggro = aggro;
        }

        public int getPotions() {
            return potions;
        }

        public void setPotions(int potions) {
            this.potions = potions;
        }

        public int getRations() {
            return rations;
        }

        public void setRations(int rations) {
            this.rations = rations;
        }

        public int getWhetstones() {
            return whetstones;
        }

        public void setWhetstones(int whetstones) {
            this.whetstones = whetstones;
        }

        public String getAttacks() {
            return attacks;
        }

        public void setAttacks(String attacks) {
            this.attacks = attacks;
        }

        public boolean isMe() {
            return getHunterID() == playerID;
        }
    }
}
\$\endgroup\$
  • 1
    \$\begingroup\$ Dat name, rofl XD \$\endgroup\$ – Maltysen Feb 26 '15 at 1:32
  • \$\begingroup\$ Roran seems to like hitting without much concern for his life. He managed to die fighting a Yian Kut-ku! He came last in my test game. \$\endgroup\$ – Thrax Feb 26 '15 at 7:57
6
\$\begingroup\$

Weasel Will

I'm not sure I entirely trust this guy, but his blades are nice to have around in case of trouble.

public class WeaselWill {
    int id, round, atk, def, hp,
        energy, guard, speed,
        sharp, aggro, potions,
        rations, whets;
    String combo;
    Monster monster;
    int[] aggros;

    void hunt(){
        if(willKillMe(false))
            dontDie();
        if(energy < 11){
            if(aggroDiff() > 300)
                output("T");
            output("W");
        }
        if(willHitMe()&&energy>29)
            output("D");
        int potDamage = attack(false);
        if(potDamage>monster.hp/2)
            attack(true);
        if(aggroDiff()*2>potDamage || round==1)
            attack(true);
        if(sharp==1&&whets>0&&!willKillMe(true))
            output("S");
        output("W");
    }

    int aggroDiff(){
        int highest = 0;
        for(int agg : aggros)
            highest = agg>highest?agg:highest;
        return highest - aggro;
    }

    int attack(boolean output){
        if(output)
            output("C");
        return willHitFor(combo.length()+1);
    }

    void dontDie(){
        if(energy>=30)
            output("D");
        int dmg = hitsMeFor(true);
        if(hp-dmg>-30 && rations>0)
            output("R");
        if(potions>0)
            output("P");
        if(energy>10)
            attack(true);
        output("W");
    }

    boolean willKillMe(boolean item){return willHitMe()&&(hitsMeFor(item)>=hp);}
    boolean willHitMe(){
        if(monster.move.equals("S"))
            return true;
        else if((monster.move.equals("A")||monster.move.equals("C"))&&monster.target==id)
            return true;
        return false;
    }

    int hitsMeFor(boolean item){
        return monster.atk*(10-def+(item?2:0));
    }

    int willHitFor(int combo){
        return atk*(10+sharp-monster.def)*combo;
    }

    static int atoi(String in){
        return Integer.parseInt(in);
    }

    void output(String out){
        System.out.println(out);
        System.exit(0);
    }

    public static void main(String[] args){
        if(args.length==0){
            System.out.println("DB");
        } else {
            new WeaselWill(args[0]).hunt();
        }
    }

    WeaselWill(String input){
        String[] tokens = input.split(";");
        round = atoi(tokens[0]);
        id = atoi(tokens[1]);
        monster = new Monster(new String[]{tokens[2],tokens[3],tokens[4],tokens[5],tokens[6]});        
        aggros = new int[3];
        for(int i=7,j=0;i<tokens.length;i++){
            String[] in = tokens[i].split("_");
            if(atoi(in[0])==id){
                atk = atoi(in[2]);
                def = atoi(in[3]);
                hp = atoi(in[4]);
                energy = atoi(in[5]);
                guard = atoi(in[6]);
                speed = atoi(in[7]);
                sharp = atoi(in[8]);
                aggro = atoi(in[9]);
                potions = atoi(in[10]);
                rations = atoi(in[11]);
                whets = atoi(in[12]);
                combo = in[13];                
            } else {
                aggros[j++] = atoi(in[9]);
            }
        }
    }

    class Monster{
        int atk, def, hp, target;
        String move;

        Monster(String[] in){
            atk = atoi(in[0]);
            def = atoi(in[1]);
            hp = atoi(in[2]);
            target = atoi(in[3]);
            move = in[4];
        }
    }
}
\$\endgroup\$
  • \$\begingroup\$ I call him Weasel because he tends to score best when Fatalis kills everyone else and he dodges until the time limit. I like to imagine he loots the corpses before heading out. \$\endgroup\$ – Geobits Feb 27 '15 at 2:49
  • \$\begingroup\$ This guy manages to make current hunters fail almost every hunt! But he does dodge pretty well! \$\endgroup\$ – Thrax Feb 27 '15 at 7:52
6
\$\begingroup\$

The King's Jester

The monsters (especially Fatalis) have an extreme dislike for his rock throwing skills.

import java.util.ArrayList;
import java.util.List;


public class TheKingsJester {

    int round;
    int playerID;
    Hunter thisHunter;
    List<Hunter> hunters = new ArrayList<>();
    List<Hunter> otherHunters = new ArrayList<>();
    Monster monster;
    boolean canTauntSafely;

    public static void main(String[] args){
        if (args.length == 0) {
            System.out.println("HA");//Ha ha ha ha
        } else {
            System.out.println(new TheKingsJester(args).hunt());
        }
    }

    private String hunt() {

        String monstersNextMove = monster.getNextMove();
        boolean rest = false;

        switch (monstersNextMove){
            case "A":
            case "C":
            case "S":
                int mostAggresiveness = 0;
                for (Hunter hunter : otherHunters){
                    mostAggresiveness = Math.max(mostAggresiveness, hunter.getAggro());
                }
                if (thisHunter.getAggro() >= mostAggresiveness || monstersNextMove.equals("S")) {
                    if (thisHunter.getEnergy() >= 30){
                        return "D";
                    }
                } else if (thisHunter.getAggro() + 300 >= mostAggresiveness) {
                    rest = true;
                }
            default:
                if (thisHunter.getHp() <= 10 && thisHunter.getPotions() > 0){
                    return "P";
                }
                int monsterAttack = monster.getAtk() * 7;
                int difference = monsterAttack - thisHunter.getHp() + 1;
                if (difference > 0){
                    if (difference <= 30 && thisHunter.getRations() > 0){
                        return "R";
                    }
                    if (thisHunter.getPotions() > 0) {
                        return "P";
                    }
                    if (thisHunter.getRations() > 0){
                        return "R";
                    }
                }
                if (rest){
                    return "W";
                }
                return "T";
        }

    }

    public TheKingsJester(String[] args) {

        args = args[0].split(";");

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);
        monster = new Monster(args[2]+";"+args[3]+";"+args[4]+";"+args[5]+";"+args[6]);


        for (int i = 7; i < args.length; i++){
            hunters.add(new Hunter(args[i]));
        }

        int mostAggressiveness = 0;
        int myAggressiveness = 0;

        for (Hunter hunter : hunters) {
            if (hunter.isMe()){
                thisHunter = hunter;
                myAggressiveness = hunter.getAggro();
            } else {
                otherHunters.add(hunter);
                mostAggressiveness = Math.max(mostAggressiveness, hunter.getAggro());
            }
        }

        canTauntSafely = myAggressiveness + 300 < mostAggressiveness;
    }

    private class Monster {

        int atk;
        int def;
        int hp;
        int targetId;
        String nextMove;

        public Monster(String string) {
            String[] args = string.split(";");
            atk = Integer.parseInt(args[0]);
            def = Integer.parseInt(args[1]);
            hp = Integer.parseInt(args[2]);
            targetId = Integer.parseInt(args[3]);
            nextMove = args[4];
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getTargetId() {
            return targetId;
        }

        public void setTargetId(int targetId) {
            this.targetId = targetId;
        }

        public String getNextMove() {
            return nextMove;
        }

        public void setNextMove(String nextMove) {
            this.nextMove = nextMove;
        }
    }

    private class Hunter {
        int hunterID;
        String weapon;
        int atk;
        int def;
        int hp;
        int energy;
        int guard;
        int speed;
        int sharpness;
        int aggro;
        int potions;
        int rations;
        int whetstones;
        String attacks;

        public Hunter(String string) {
            String[] args = string.split("_");
            hunterID = Integer.parseInt(args[0]);
            weapon = args[1];
            atk = Integer.parseInt(args[2]);
            def = Integer.parseInt(args[3]);
            hp = Integer.parseInt(args[4]);
            energy = Integer.parseInt(args[5]);
            guard = Integer.parseInt(args[6]);
            speed = Integer.parseInt(args[7]);
            sharpness = Integer.parseInt(args[8]);
            aggro = Integer.parseInt(args[9]);
            potions = Integer.parseInt(args[10]);
            rations = Integer.parseInt(args[11]);
            whetstones = Integer.parseInt(args[12]);
            attacks = args[13];
        }

        public int getHunterID() {
            return hunterID;
        }

        public void setHunterID(int hunterID) {
            this.hunterID = hunterID;
        }

        public String getWeapon() {
            return weapon;
        }

        public void setWeapon(String weapon) {
            this.weapon = weapon;
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getEnergy() {
            return energy;
        }

        public void setEnergy(int energy) {
            this.energy = energy;
        }

        public int getGuard() {
            return guard;
        }

        public void setGuard(int guard) {
            this.guard = guard;
        }

        public int getSpeed() {
            return speed;
        }

        public void setSpeed(int speed) {
            this.speed = speed;
        }

        public int getSharpness() {
            return sharpness;
        }

        public void setSharpness(int sharpness) {
            this.sharpness = sharpness;
        }

        public int getAggro() {
            return aggro;
        }

        public void setAggro(int aggro) {
            this.aggro = aggro;
        }

        public int getPotions() {
            return potions;
        }

        public void setPotions(int potions) {
            this.potions = potions;
        }

        public int getRations() {
            return rations;
        }

        public void setRations(int rations) {
            this.rations = rations;
        }

        public int getWhetstones() {
            return whetstones;
        }

        public void setWhetstones(int whetstones) {
            this.whetstones = whetstones;
        }

        public String getAttacks() {
            return attacks;
        }

        public void setAttacks(String attacks) {
            this.attacks = attacks;
        }

        public boolean isMe() {
            return getHunterID() == playerID;
        }
    }
}
\$\endgroup\$
  • \$\begingroup\$ Interesting strategy. At least The King's Jester score is an easy to remember number. \$\endgroup\$ – Thrax Mar 2 '15 at 11:00
  • \$\begingroup\$ While this one doesn't seem to score particularly well, I like having him as a partner. He actually makes a pretty good tank by keeping the monster's attention and dodging attacks. \$\endgroup\$ – Spencer Mar 2 '15 at 21:02
6
\$\begingroup\$

RedViper

Waits for the right moment to strike.

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class RedViper {
    private static final int ENERGY_PER_GUARD = 15;
    private static final int ENERGY_PER_HIT = 20;
    private static final String FILE_PATH = "RedViper.txt";

    int round;
    int playerID;
    Hunter me;
    List<Hunter> otherHunters = new ArrayList<>();;
    Monster monster;

    public static void main(String[] args){
        if (args.length == 0) {
            System.out.println("LA");
        } else {
            RedViper redViper = new RedViper(args);
            String output = redViper.hunt();
            redViper.updateDataFile();
            System.out.println(output);
        }
    }

    private void updateDataFile() {
        File f = new File(FILE_PATH);
        if (f.exists())
            f.delete();
        if(monster.nextMove.equals("F") || monster.nextMove.equals("C")) {
            try {
                f.createNewFile();
            } catch (IOException e) {}
        }
    }

    private String hunt() {
        //low hp
        if (me.hp <= monster.dmg(me, false, false)) {
            if (!monster.attacksMe()) {
                if (me.potions > 0)
                    return "P";
                else if (me.rations > 0)
                    return "R";
            } else {
                if (me.hp > monster.dmg(me, true, false) && me.energy > ENERGY_PER_GUARD)
                    return "G";
                else if (me.potions > 0)
                    return "P";
                else if (me.rations > 0 && me.hp + 30 > monster.dmg(me, false, true))
                    return "R";
                else
                    return "B";
            }
        }
        if (monster.attacksMe() && me.energy >= ENERGY_PER_GUARD)
            return "G";
        if (isSafeToTaunt() && me.energy < 80)
            return "T";
        if (!monster.attacksMe() 
                && !(me.attacks.equals("BB") && me.energy >= ENERGY_PER_HIT && !monster.dodges()) 
                && !(me.attacks.equals("B") && me.energy >= ENERGY_PER_HIT*2) 
                && round < 48) {
            if (me.sharpness < 2 && me.whetstones > 0)
                return "S";
            if (me.energy <= 50 && me.hp <= 70 && me.rations > 0)
                return "R";
        }
        if ((monster.dodges() && !(me.attacks.equals("B") && me.energy >= ENERGY_PER_HIT*2)) || me.energy < ENERGY_PER_HIT)
            return "W";

        return "B";
    }

    private boolean isSafeToTaunt() {
        int highestAggro = Integer.MIN_VALUE;
        for (Hunter hunter : otherHunters) {
            if (hunter.aggro > highestAggro)
                highestAggro = hunter.aggro;
        }
        return highestAggro > me.aggro + 300;
    }

    public RedViper(String[] args) {
        List<Hunter> allHunters = new ArrayList<>();
        args = args[0].split(";");

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);
        monster = new Monster(args[2]+";"+args[3]+";"+args[4]+";"+args[5]+";"+args[6]);

        for (int i = 7; i < args.length; i++){
            allHunters.add(new Hunter(args[i]));
        }

        for (Hunter hunter : allHunters) {
            if (hunter.isMe()){
                me = hunter;
            } else {
                otherHunters.add(hunter);
            }
        }
    }

    private class Monster {

        int atk;
        int targetId;
        String nextMove;

        public Monster(String string) {
            String[] args = string.split(";");
            atk = Integer.parseInt(args[0]);
            targetId = Integer.parseInt(args[3]);
            nextMove = args[4];
        }

        public boolean attacksMe() {
            return nextMove.equals("S") 
                    || (nextMove.equals("C") && targetId == playerID)
                    || (nextMove.equals("A") && targetId == playerID);
        }

        public int dmg(Hunter hunter, boolean guard, boolean using) {
            int damageMultiplicator = 10 - hunter.def;
            if (guard) { damageMultiplicator -= hunter.guard; }
            if (using) { damageMultiplicator += 2; }

            int damage = monster.atk * damageMultiplicator;
            return damage;
        }

        public boolean dodges() {
            File f = new File(FILE_PATH);
            return f.exists();
        }
    }

    private class Hunter {
        int id;
        int def;
        int hp;
        int energy;
        int guard;
        int sharpness;
        int aggro;
        int potions;
        int rations;
        int whetstones;
        String attacks;

        public Hunter(String string) {
            String[] args = string.split("_");
            id = Integer.parseInt(args[0]);
            def = Integer.parseInt(args[3]);
            hp = Integer.parseInt(args[4]);
            energy = Integer.parseInt(args[5]);
            guard = Integer.parseInt(args[6]);
            sharpness = Integer.parseInt(args[8]);
            aggro = Integer.parseInt(args[9]);
            potions = Integer.parseInt(args[10]);
            rations = Integer.parseInt(args[11]);
            whetstones = Integer.parseInt(args[12]);
            attacks = args[13];
        }

        public boolean isMe() {
            return id == playerID;
        }
    }
}
\$\endgroup\$
  • \$\begingroup\$ RedViper is doing pretty well, he ended up in 1st or 2nd every time. \$\endgroup\$ – Thrax Feb 26 '15 at 13:01
5
\$\begingroup\$

Java, Felyne (helper)

One of the 4 example bots. This one wields a Lance.

import java.util.ArrayList;
import java.util.List;


public class Felyne {

    private static final int ENERGY_PER_DODGE = 30;
    private static final int ENERGY_PER_GUARD = 15;
    private static final int ENERGY_PER_WAIT = 30;
    private static final int ENERGY_PER_TAUNT = 80;
    private static final int AGGRO_PER_TAUNT = 300;

    int round;
    int playerID;
    Hunter thisHunter;
    List<Hunter> hunters = new ArrayList<>();;
    List<Hunter> otherHunters = new ArrayList<>();;
    Monster monster;

    public static void main(String[] args){
        if (args.length == 0) {
            System.out.println("LA");
        } else {
            System.out.println(new Felyne(args).hunt());
        }
    }

    private String hunt() {

        if (thisHunter.getHp() <= (monster.getAtk() * 5)) {
            if (thisHunter.getPotions() > 0) 
                return "P";
            else if (thisHunter.getRations() > 0)
                return "R";
            else if (thisHunter.getEnergy() > ENERGY_PER_GUARD)
                return "G";
            else
                return attack();
        } else if (monster.getTargetId() == playerID) {
            if (thisHunter.getEnergy() > ENERGY_PER_GUARD)
                return "G";
            else
                return attack();
        } else if (thisHunter.getSharpness() < 2) {
            if (thisHunter.getWhetstones() > 0)
                return "S";
            else 
                return attack();
        } else {
            return attack();
        }
    }

    private String attack() {

        int energyPerHit = Math.floorDiv(100, thisHunter.getSpeed() + 2);

        // Lance Combos : AAA, AAAC, BBB
        if (thisHunter.getEnergy() >= (energyPerHit * 4) && thisHunter.getAttacks().equals("N")) 
            return "A";
        else if (thisHunter.getEnergy() <= (energyPerHit * 4) && thisHunter.getAttacks().equals("N"))
            if (100 - thisHunter.getAggro() <= ENERGY_PER_TAUNT && thisHunter.getAggro() < (otherHunters.stream().max((x, y) -> x.getAggro() - y.getAggro()).get().getAggro() + AGGRO_PER_TAUNT + 1))
                return "T";
            else
                return "W";
        else if (thisHunter.getEnergy() >= (energyPerHit * 3) && thisHunter.getAttacks().equals("A"))
            return "A";
        else if (thisHunter.getEnergy() >= (energyPerHit * 2) && thisHunter.getAttacks().equals("AA"))
            return "A";
        else if (thisHunter.getEnergy() >= (energyPerHit * 1) && thisHunter.getAttacks().equals("AAA"))
            return "C";
        else
            return "W";
    }

    public Felyne(String[] args) {

        args = args[0].split(";");

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);
        monster = new Monster(args[2]+";"+args[3]+";"+args[4]+";"+args[5]+";"+args[6]);


        for (int i = 7; i < args.length; i++){
            hunters.add(new Hunter(args[i]));
        }

        for (Hunter hunter : hunters) {
            if (hunter.isMe()){
                thisHunter = hunter;
            } else {
                otherHunters.add(hunter);
            }
        }
    }

    private class Monster {

        int atk;
        int def;
        int hp;
        int targetId;
        String nextMove;

        public Monster(String string) {
            String[] args = string.split(";");
            atk = Integer.parseInt(args[0]);
            def = Integer.parseInt(args[1]);
            hp = Integer.parseInt(args[2]);
            targetId = Integer.parseInt(args[3]);
            nextMove = args[4];
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getTargetId() {
            return targetId;
        }

        public void setTargetId(int targetId) {
            this.targetId = targetId;
        }

        public String getNextMove() {
            return nextMove;
        }

        public void setNextMove(String nextMove) {
            this.nextMove = nextMove;
        }
    }

    private class Hunter {
        int hunterID;
        String weapon;
        int atk;
        int def;
        int hp;
        int energy;
        int guard;
        int speed;
        int sharpness;
        int aggro;
        int potions;
        int rations;
        int whetstones;
        String attacks;

        public Hunter(String string) {
            String[] args = string.split("_");
            hunterID = Integer.parseInt(args[0]);
            weapon = args[1];
            atk = Integer.parseInt(args[2]);
            def = Integer.parseInt(args[3]);
            hp = Integer.parseInt(args[4]);
            energy = Integer.parseInt(args[5]);
            guard = Integer.parseInt(args[6]);
            speed = Integer.parseInt(args[7]);
            sharpness = Integer.parseInt(args[8]);
            aggro = Integer.parseInt(args[9]);
            potions = Integer.parseInt(args[10]);
            rations = Integer.parseInt(args[11]);
            whetstones = Integer.parseInt(args[12]);
            attacks = args[13];
        }

        public int getHunterID() {
            return hunterID;
        }

        public void setHunterID(int hunterID) {
            this.hunterID = hunterID;
        }

        public String getWeapon() {
            return weapon;
        }

        public void setWeapon(String weapon) {
            this.weapon = weapon;
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getEnergy() {
            return energy;
        }

        public void setEnergy(int energy) {
            this.energy = energy;
        }

        public int getGuard() {
            return guard;
        }

        public void setGuard(int guard) {
            this.guard = guard;
        }

        public int getSpeed() {
            return speed;
        }

        public void setSpeed(int speed) {
            this.speed = speed;
        }

        public int getSharpness() {
            return sharpness;
        }

        public void setSharpness(int sharpness) {
            this.sharpness = sharpness;
        }

        public int getAggro() {
            return aggro;
        }

        public void setAggro(int aggro) {
            this.aggro = aggro;
        }

        public int getPotions() {
            return potions;
        }

        public void setPotions(int potions) {
            this.potions = potions;
        }

        public int getRations() {
            return rations;
        }

        public void setRations(int rations) {
            this.rations = rations;
        }

        public int getWhetstones() {
            return whetstones;
        }

        public void setWhetstones(int whetstones) {
            this.whetstones = whetstones;
        }

        public String getAttacks() {
            return attacks;
        }

        public void setAttacks(String attacks) {
            this.attacks = attacks;
        }

        public boolean isMe() {
            return getHunterID() == playerID;
        }
    }
}
\$\endgroup\$
  • \$\begingroup\$ So this sample bot tops the scoreboard? \$\endgroup\$ – justhalf Mar 4 '15 at 7:10
  • \$\begingroup\$ @justhalf For now, and my guess is RNG Jesus had a lot to do with its victory. \$\endgroup\$ – Thrax Mar 4 '15 at 7:46
  • \$\begingroup\$ If you suspect RNG has a lot to do with this, then I think we can increase the number of hunts to, say, 30 or 50. \$\endgroup\$ – justhalf Mar 4 '15 at 7:47
  • 1
    \$\begingroup\$ @justhalf I think I'll do 100 hunts for the final game, but I'll only do 10 for test games. \$\endgroup\$ – Thrax Mar 4 '15 at 7:49
3
\$\begingroup\$

Java, Koneko (helper)

One one of the 4 example bot. This one wields Dual Blades

import java.util.ArrayList;
import java.util.List;


public class Koneko {

    private static final int ENERGY_PER_DODGE = 30;
    private static final int ENERGY_PER_GUARD = 15;
    private static final int ENERGY_PER_WAIT = 30;
    private static final int ENERGY_PER_TAUNT = 80;
    private static final int AGGRO_PER_TAUNT = 300;

    int round;
    int playerID;
    Hunter thisHunter;
    List<Hunter> hunters = new ArrayList<>();;
    List<Hunter> otherHunters = new ArrayList<>();;
    Monster monster;

    public static void main(String[] args){
        if (args.length == 0) {
            System.out.println("DB");
        } else {
            System.out.println(new Koneko(args).hunt());
        }
    }

    private String hunt() {

        if (thisHunter.getHp() <= (monster.getAtk() * 5)) {
            if (thisHunter.getPotions() > 0) 
                return "P";
            else if (thisHunter.getRations() > 0)
                return "R";
            else if (thisHunter.getEnergy() > ENERGY_PER_GUARD)
                return "G";
            else
                return attack();
        } else if (monster.getTargetId() == playerID) {
            if (thisHunter.getEnergy() > ENERGY_PER_GUARD)
                return "G";
            else
                return attack();
        } else if (thisHunter.getSharpness() < 2) {
            if (thisHunter.getWhetstones() > 0)
                return "S";
            else 
                return attack();
        } else {
            return attack();
        }
    }

    private String attack() {

        int energyPerHit = Math.floorDiv(100, thisHunter.getSpeed() + 2);

        // Dual Blade Combos : CC, ABAB, ABABA, ABABAC
        if (thisHunter.getEnergy() >= (energyPerHit * 6) && thisHunter.getAttacks().equals("N")) 
            return "A";
        else if (thisHunter.getEnergy() <= (energyPerHit * 6) && thisHunter.getAttacks().equals("N"))
            if (100 - thisHunter.getAggro() <= ENERGY_PER_TAUNT && thisHunter.getAggro() < (otherHunters.stream().max((x, y) -> x.getAggro() - y.getAggro()).get().getAggro() + AGGRO_PER_TAUNT + 1))
                return "T";
            else
                return "W";
        else if (thisHunter.getEnergy() >= (energyPerHit * 5) && thisHunter.getAttacks().equals("A"))
            return "B";
        else if (thisHunter.getEnergy() >= (energyPerHit * 4) && thisHunter.getAttacks().equals("AB"))
            return "A";
        else if (thisHunter.getEnergy() >= (energyPerHit * 3) && thisHunter.getAttacks().equals("ABA"))
            return "B";
        else if (thisHunter.getEnergy() >= (energyPerHit * 2) && thisHunter.getAttacks().equals("ABAB"))
            return "A";
        else if (thisHunter.getEnergy() >= (energyPerHit * 1) && thisHunter.getAttacks().equals("ABABA"))
            return "C";
        else
            return "W";
    }

    public Koneko(String[] args) {

        args = args[0].split(";");

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);
        monster = new Monster(args[2]+";"+args[3]+";"+args[4]+";"+args[5]+";"+args[6]);


        for (int i = 7; i < args.length; i++){
            hunters.add(new Hunter(args[i]));
        }

        for (Hunter hunter : hunters) {
            if (hunter.isMe()){
                thisHunter = hunter;
            } else {
                otherHunters.add(hunter);
            }
        }
    }

    private class Monster {

        int atk;
        int def;
        int hp;
        int targetId;
        String nextMove;

        public Monster(String string) {
            String[] args = string.split(";");
            atk = Integer.parseInt(args[0]);
            def = Integer.parseInt(args[1]);
            hp = Integer.parseInt(args[2]);
            targetId = Integer.parseInt(args[3]);
            nextMove = args[4];
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getTargetId() {
            return targetId;
        }

        public void setTargetId(int targetId) {
            this.targetId = targetId;
        }

        public String getNextMove() {
            return nextMove;
        }

        public void setNextMove(String nextMove) {
            this.nextMove = nextMove;
        }
    }

    private class Hunter {
        int hunterID;
        String weapon;
        int atk;
        int def;
        int hp;
        int energy;
        int guard;
        int speed;
        int sharpness;
        int aggro;
        int potions;
        int rations;
        int whetstones;
        String attacks;

        public Hunter(String string) {
            String[] args = string.split("_");
            hunterID = Integer.parseInt(args[0]);
            weapon = args[1];
            atk = Integer.parseInt(args[2]);
            def = Integer.parseInt(args[3]);
            hp = Integer.parseInt(args[4]);
            energy = Integer.parseInt(args[5]);
            guard = Integer.parseInt(args[6]);
            speed = Integer.parseInt(args[7]);
            sharpness = Integer.parseInt(args[8]);
            aggro = Integer.parseInt(args[9]);
            potions = Integer.parseInt(args[10]);
            rations = Integer.parseInt(args[11]);
            whetstones = Integer.parseInt(args[12]);
            attacks = args[13];
        }

        public int getHunterID() {
            return hunterID;
        }

        public void setHunterID(int hunterID) {
            this.hunterID = hunterID;
        }

        public String getWeapon() {
            return weapon;
        }

        public void setWeapon(String weapon) {
            this.weapon = weapon;
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getEnergy() {
            return energy;
        }

        public void setEnergy(int energy) {
            this.energy = energy;
        }

        public int getGuard() {
            return guard;
        }

        public void setGuard(int guard) {
            this.guard = guard;
        }

        public int getSpeed() {
            return speed;
        }

        public void setSpeed(int speed) {
            this.speed = speed;
        }

        public int getSharpness() {
            return sharpness;
        }

        public void setSharpness(int sharpness) {
            this.sharpness = sharpness;
        }

        public int getAggro() {
            return aggro;
        }

        public void setAggro(int aggro) {
            this.aggro = aggro;
        }

        public int getPotions() {
            return potions;
        }

        public void setPotions(int potions) {
            this.potions = potions;
        }

        public int getRations() {
            return rations;
        }

        public void setRations(int rations) {
            this.rations = rations;
        }

        public int getWhetstones() {
            return whetstones;
        }

        public void setWhetstones(int whetstones) {
            this.whetstones = whetstones;
        }

        public String getAttacks() {
            return attacks;
        }

        public void setAttacks(String attacks) {
            this.attacks = attacks;
        }

        public boolean isMe() {
            return getHunterID() == playerID;
        }
    }
}
\$\endgroup\$
3
\$\begingroup\$

Java, Palico (helper)

One of the 4 example bots. This one wields a Hammer.

import java.util.ArrayList;
import java.util.List;


public class Palico {

    private static final int ENERGY_PER_DODGE = 30;
    private static final int ENERGY_PER_GUARD = 15;
    private static final int ENERGY_PER_WAIT = 30;
    private static final int ENERGY_PER_TAUNT = 80;
    private static final int AGGRO_PER_TAUNT = 300;

    int round;
    int playerID;
    Hunter thisHunter;
    List<Hunter> hunters = new ArrayList<>();;
    List<Hunter> otherHunters = new ArrayList<>();;
    Monster monster;

    public static void main(String[] args){
        if (args.length == 0) {
            System.out.println("HA");
        } else {
            System.out.println(new Palico(args).hunt());
        }
    }

    private String hunt() {

        if (thisHunter.getHp() <= (monster.getAtk() * 5)) {
            if (thisHunter.getPotions() > 0) 
                return "P";
            else if (thisHunter.getRations() > 0)
                return "R";
            else if (thisHunter.getEnergy() > ENERGY_PER_GUARD)
                return "G";
            else
                return attack();
        } else if (monster.getTargetId() == playerID) {
            if (thisHunter.getEnergy() > ENERGY_PER_GUARD)
                return "G";
            else
                return attack();
        } else if (thisHunter.getSharpness() < 2) {
            if (thisHunter.getWhetstones() > 0)
                return "S";
            else 
                return attack();
        } else {
            return attack();
        }
    }

    private String attack() {

        int energyPerHit = Math.floorDiv(100, thisHunter.getSpeed() + 2);

        // Hammer Combos : CCA, BBA
        if (thisHunter.getEnergy() >= (energyPerHit * 3) && thisHunter.getAttacks().equals("N")) 
            return "C";
        else if (thisHunter.getEnergy() <= (energyPerHit * 3) && thisHunter.getAttacks().equals("N"))
            if (100 - thisHunter.getAggro() <= ENERGY_PER_TAUNT && thisHunter.getAggro() < (otherHunters.stream().max((x, y) -> x.getAggro() - y.getAggro()).get().getAggro() + AGGRO_PER_TAUNT + 1))
                return "T";
            else
                return "W";
        else if (thisHunter.getEnergy() >= (energyPerHit * 3) && thisHunter.getAttacks().equals("C"))
            return "C";
        else if (thisHunter.getEnergy() >= (energyPerHit * 2) && thisHunter.getAttacks().equals("CC"))
            return "A";
        else
            return "W";
    }

    public Palico(String[] args) {

        args = args[0].split(";");

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);
        monster = new Monster(args[2]+";"+args[3]+";"+args[4]+";"+args[5]+";"+args[6]);


        for (int i = 7; i < args.length; i++){
            hunters.add(new Hunter(args[i]));
        }

        for (Hunter hunter : hunters) {
            if (hunter.isMe()){
                thisHunter = hunter;
            } else {
                otherHunters.add(hunter);
            }
        }
    }

    private class Monster {

        int atk;
        int def;
        int hp;
        int targetId;
        String nextMove;

        public Monster(String string) {
            String[] args = string.split(";");
            atk = Integer.parseInt(args[0]);
            def = Integer.parseInt(args[1]);
            hp = Integer.parseInt(args[2]);
            targetId = Integer.parseInt(args[3]);
            nextMove = args[4];
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getTargetId() {
            return targetId;
        }

        public void setTargetId(int targetId) {
            this.targetId = targetId;
        }

        public String getNextMove() {
            return nextMove;
        }

        public void setNextMove(String nextMove) {
            this.nextMove = nextMove;
        }
    }

    private class Hunter {
        int hunterID;
        String weapon;
        int atk;
        int def;
        int hp;
        int energy;
        int guard;
        int speed;
        int sharpness;
        int aggro;
        int potions;
        int rations;
        int whetstones;
        String attacks;

        public Hunter(String string) {
            String[] args = string.split("_");
            hunterID = Integer.parseInt(args[0]);
            weapon = args[1];
            atk = Integer.parseInt(args[2]);
            def = Integer.parseInt(args[3]);
            hp = Integer.parseInt(args[4]);
            energy = Integer.parseInt(args[5]);
            guard = Integer.parseInt(args[6]);
            speed = Integer.parseInt(args[7]);
            sharpness = Integer.parseInt(args[8]);
            aggro = Integer.parseInt(args[9]);
            potions = Integer.parseInt(args[10]);
            rations = Integer.parseInt(args[11]);
            whetstones = Integer.parseInt(args[12]);
            attacks = args[13];
        }

        public int getHunterID() {
            return hunterID;
        }

        public void setHunterID(int hunterID) {
            this.hunterID = hunterID;
        }

        public String getWeapon() {
            return weapon;
        }

        public void setWeapon(String weapon) {
            this.weapon = weapon;
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getEnergy() {
            return energy;
        }

        public void setEnergy(int energy) {
            this.energy = energy;
        }

        public int getGuard() {
            return guard;
        }

        public void setGuard(int guard) {
            this.guard = guard;
        }

        public int getSpeed() {
            return speed;
        }

        public void setSpeed(int speed) {
            this.speed = speed;
        }

        public int getSharpness() {
            return sharpness;
        }

        public void setSharpness(int sharpness) {
            this.sharpness = sharpness;
        }

        public int getAggro() {
            return aggro;
        }

        public void setAggro(int aggro) {
            this.aggro = aggro;
        }

        public int getPotions() {
            return potions;
        }

        public void setPotions(int potions) {
            this.potions = potions;
        }

        public int getRations() {
            return rations;
        }

        public void setRations(int rations) {
            this.rations = rations;
        }

        public int getWhetstones() {
            return whetstones;
        }

        public void setWhetstones(int whetstones) {
            this.whetstones = whetstones;
        }

        public String getAttacks() {
            return attacks;
        }

        public void setAttacks(String attacks) {
            this.attacks = attacks;
        }

        public boolean isMe() {
            return getHunterID() == playerID;
        }
    }
}
\$\endgroup\$
3
\$\begingroup\$

Java, Melynx (helper)

One of the 4 example bots. This one wields a Great Sword.

import java.util.ArrayList;
import java.util.List;


public class Melynx {

    private static final int ENERGY_PER_DODGE = 30;
    private static final int ENERGY_PER_GUARD = 15;
    private static final int ENERGY_PER_WAIT = 30;
    private static final int ENERGY_PER_TAUNT = 80;
    private static final int AGGRO_PER_TAUNT = 300;

    int round;
    int playerID;
    Hunter thisHunter;
    List<Hunter> hunters = new ArrayList<>();;
    List<Hunter> otherHunters = new ArrayList<>();;
    Monster monster;

    public static void main(String[] args){
        if (args.length == 0) {
            System.out.println("GS");
        } else {
            System.out.println(new Melynx(args).hunt());
        }
    }

    private String hunt() {

        if (thisHunter.getHp() <= (monster.getAtk() * 5)) {
            if (thisHunter.getPotions() > 0) 
                return "P";
            else if (thisHunter.getRations() > 0)
                return "R";
            else if (thisHunter.getEnergy() > ENERGY_PER_GUARD)
                return "G";
            else
                return attack();
        } else if (monster.getTargetId() == playerID) {
            if (thisHunter.getEnergy() > ENERGY_PER_GUARD)
                return "G";
            else
                return attack();
        } else if (thisHunter.getSharpness() < 2) {
            if (thisHunter.getWhetstones() > 0)
                return "S";
            else 
                return attack();
        } else {
            return attack();
        }
    }

    private String attack() {

        int energyPerHit = Math.floorDiv(100, thisHunter.getSpeed() + 2);

        // Great Sword Combos : BBA, BBBC
        if (thisHunter.getEnergy() >= (energyPerHit * 4) && thisHunter.getAttacks().equals("N")) 
            return "B";
        else if (thisHunter.getEnergy() <= (energyPerHit * 4) && thisHunter.getAttacks().equals("N"))
            if (100 - thisHunter.getAggro() <= ENERGY_PER_TAUNT && thisHunter.getAggro() < (otherHunters.stream().max((x, y) -> x.getAggro() - y.getAggro()).get().getAggro() + AGGRO_PER_TAUNT + 1))
                return "T";
            else
                return "W";
        else if (thisHunter.getEnergy() >= (energyPerHit * 3) && thisHunter.getAttacks().equals("B"))
            return "B";
        else if (thisHunter.getEnergy() >= (energyPerHit * 2) && thisHunter.getAttacks().equals("BB"))
            return "B";
        else if (thisHunter.getEnergy() >= (energyPerHit * 1) && thisHunter.getAttacks().equals("BBB"))
            return "C";
        else
            return "W";
    }

    public Melynx(String[] args) {

        args = args[0].split(";");

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);
        monster = new Monster(args[2]+";"+args[3]+";"+args[4]+";"+args[5]+";"+args[6]);


        for (int i = 7; i < args.length; i++){
            hunters.add(new Hunter(args[i]));
        }

        for (Hunter hunter : hunters) {
            if (hunter.isMe()){
                thisHunter = hunter;
            } else {
                otherHunters.add(hunter);
            }
        }
    }

    private class Monster {

        int atk;
        int def;
        int hp;
        int targetId;
        String nextMove;

        public Monster(String string) {
            String[] args = string.split(";");
            atk = Integer.parseInt(args[0]);
            def = Integer.parseInt(args[1]);
            hp = Integer.parseInt(args[2]);
            targetId = Integer.parseInt(args[3]);
            nextMove = args[4];
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getTargetId() {
            return targetId;
        }

        public void setTargetId(int targetId) {
            this.targetId = targetId;
        }

        public String getNextMove() {
            return nextMove;
        }

        public void setNextMove(String nextMove) {
            this.nextMove = nextMove;
        }
    }

    private class Hunter {
        int hunterID;
        String weapon;
        int atk;
        int def;
        int hp;
        int energy;
        int guard;
        int speed;
        int sharpness;
        int aggro;
        int potions;
        int rations;
        int whetstones;
        String attacks;

        public Hunter(String string) {
            String[] args = string.split("_");
            hunterID = Integer.parseInt(args[0]);
            weapon = args[1];
            atk = Integer.parseInt(args[2]);
            def = Integer.parseInt(args[3]);
            hp = Integer.parseInt(args[4]);
            energy = Integer.parseInt(args[5]);
            guard = Integer.parseInt(args[6]);
            speed = Integer.parseInt(args[7]);
            sharpness = Integer.parseInt(args[8]);
            aggro = Integer.parseInt(args[9]);
            potions = Integer.parseInt(args[10]);
            rations = Integer.parseInt(args[11]);
            whetstones = Integer.parseInt(args[12]);
            attacks = args[13];
        }

        public int getHunterID() {
            return hunterID;
        }

        public void setHunterID(int hunterID) {
            this.hunterID = hunterID;
        }

        public String getWeapon() {
            return weapon;
        }

        public void setWeapon(String weapon) {
            this.weapon = weapon;
        }

        public int getAtk() {
            return atk;
        }

        public void setAtk(int atk) {
            this.atk = atk;
        }

        public int getDef() {
            return def;
        }

        public void setDef(int def) {
            this.def = def;
        }

        public int getHp() {
            return hp;
        }

        public void setHp(int hp) {
            this.hp = hp;
        }

        public int getEnergy() {
            return energy;
        }

        public void setEnergy(int energy) {
            this.energy = energy;
        }

        public int getGuard() {
            return guard;
        }

        public void setGuard(int guard) {
            this.guard = guard;
        }

        public int getSpeed() {
            return speed;
        }

        public void setSpeed(int speed) {
            this.speed = speed;
        }

        public int getSharpness() {
            return sharpness;
        }

        public void setSharpness(int sharpness) {
            this.sharpness = sharpness;
        }

        public int getAggro() {
            return aggro;
        }

        public void setAggro(int aggro) {
            this.aggro = aggro;
        }

        public int getPotions() {
            return potions;
        }

        public void setPotions(int potions) {
            this.potions = potions;
        }

        public int getRations() {
            return rations;
        }

        public void setRations(int rations) {
            this.rations = rations;
        }

        public int getWhetstones() {
            return whetstones;
        }

        public void setWhetstones(int whetstones) {
            this.whetstones = whetstones;
        }

        public String getAttacks() {
            return attacks;
        }

        public void setAttacks(String attacks) {
            this.attacks = attacks;
        }

        public boolean isMe() {
            return getHunterID() == playerID;
        }
    }
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.