Skip to main content
added 2 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Inside Your Head, Ruby

  • Brian: Psychic, Attack: 100, Defence: 50, Speed: 80, Pain, Fireball, Watergun
  • Elemon1: Psychic, Attack: 100, Defence: 50, Speed: 80, Fireball, Watergun, Vine
  • Elemon2: Psychic, Attack: 100, Defence: 50, Speed: 80, Fireball, Watergun, Vine
TEAM_SPEC = "InsideYourHead"+
            "|Brian:1:100:50:80:3:6:9"+
            "|Elemon1:1:100:50:80:6:9:12"+
            "|Elemon2:1:100:50:80:6:9:12"

def parse_battle_state request
    request.map do |team_state|
        state = {}
        parts = team_state.split '|'
        state[:active] = parts.shift.split(':')[1].to_i
        state[:monsters] = parts.map do |monster_state|
            monster = {}
            parts = monster_state.split(':')
            monster[:name] = parts[0]
            monster[:hp] = parts[5].to_i
            monster[:type] = parts[6].to_i
            monster
        end
        state
    end
end

request = ARGV[0].split '#'
case request.shift
when 'T'
    puts TEAM_SPEC
when 'C'
    battle_state = parse_battle_state request
    my_state = battle_state[0]
    puts my_state[:monsters].find_index {|monster| monster[:hp] > 0}
when 'A'
    battle_state = parse_battle_state request
    my_state, their_state = *battle_state
    my_monster = my_state[:monsters][my_state[:active]]
    their_monster = their_state[:monsters][their_state[:active]]
    puts [1,0,1,2,0][their_monster[:type]]
when 'B'
    puts '0:0:0'
end

Run with

ruby InsideYourHead.rb

I haven't tested thisThis doesn't work very well against Manu's bot yet, but it beats the other three. The team and monster names are pretty random... I might change them if I come up with something better

The strategy is pretty simple: attack! All three monsters only have pure attack moves, and they choose their move based on the opponent's monster's type.

I might experiment with throwing in a Heal later.

Inside Your Head, Ruby

  • Brian: Psychic, Attack: 100, Defence: 50, Speed: 80, Pain, Fireball, Watergun
  • Elemon1: Psychic, Attack: 100, Defence: 50, Speed: 80, Fireball, Watergun, Vine
  • Elemon2: Psychic, Attack: 100, Defence: 50, Speed: 80, Fireball, Watergun, Vine
TEAM_SPEC = "InsideYourHead"+
            "|Brian:1:100:50:80:3:6:9"+
            "|Elemon1:1:100:50:80:6:9:12"+
            "|Elemon2:1:100:50:80:6:9:12"

def parse_battle_state request
    request.map do |team_state|
        state = {}
        parts = team_state.split '|'
        state[:active] = parts.shift.split(':')[1].to_i
        state[:monsters] = parts.map do |monster_state|
            monster = {}
            parts = monster_state.split(':')
            monster[:name] = parts[0]
            monster[:hp] = parts[5].to_i
            monster[:type] = parts[6].to_i
            monster
        end
        state
    end
end

request = ARGV[0].split '#'
case request.shift
when 'T'
    puts TEAM_SPEC
when 'C'
    battle_state = parse_battle_state request
    my_state = battle_state[0]
    puts my_state[:monsters].find_index {|monster| monster[:hp] > 0}
when 'A'
    battle_state = parse_battle_state request
    my_state, their_state = *battle_state
    my_monster = my_state[:monsters][my_state[:active]]
    their_monster = their_state[:monsters][their_state[:active]]
    puts [1,0,1,2,0][their_monster[:type]]
when 'B'
    puts '0:0:0'
end

Run with

ruby InsideYourHead.rb

I haven't tested this against Manu's bot yet, but it beats the other three. The team and monster names are pretty random... I might change them if I come up with something better

The strategy is pretty simple: attack! All three monsters only have pure attack moves, and they choose their move based on the opponent's monster's type.

I might experiment with throwing in a Heal later.

Inside Your Head, Ruby

  • Brian: Psychic, Attack: 100, Defence: 50, Speed: 80, Pain, Fireball, Watergun
  • Elemon1: Psychic, Attack: 100, Defence: 50, Speed: 80, Fireball, Watergun, Vine
  • Elemon2: Psychic, Attack: 100, Defence: 50, Speed: 80, Fireball, Watergun, Vine
TEAM_SPEC = "InsideYourHead"+
            "|Brian:1:100:50:80:3:6:9"+
            "|Elemon1:1:100:50:80:6:9:12"+
            "|Elemon2:1:100:50:80:6:9:12"

def parse_battle_state request
    request.map do |team_state|
        state = {}
        parts = team_state.split '|'
        state[:active] = parts.shift.split(':')[1].to_i
        state[:monsters] = parts.map do |monster_state|
            monster = {}
            parts = monster_state.split(':')
            monster[:name] = parts[0]
            monster[:hp] = parts[5].to_i
            monster[:type] = parts[6].to_i
            monster
        end
        state
    end
end

request = ARGV[0].split '#'
case request.shift
when 'T'
    puts TEAM_SPEC
when 'C'
    battle_state = parse_battle_state request
    my_state = battle_state[0]
    puts my_state[:monsters].find_index {|monster| monster[:hp] > 0}
when 'A'
    battle_state = parse_battle_state request
    my_state, their_state = *battle_state
    my_monster = my_state[:monsters][my_state[:active]]
    their_monster = their_state[:monsters][their_state[:active]]
    puts [1,0,1,2,0][their_monster[:type]]
when 'B'
    puts '0:0:0'
end

Run with

ruby InsideYourHead.rb

This doesn't work very well against Manu's bot, but it beats the other three. The team and monster names are pretty random... I might change them if I come up with something better

The strategy is pretty simple: attack! All three monsters only have pure attack moves, and they choose their move based on the opponent's monster's type.

I might experiment with throwing in a Heal later.

Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Inside Your Head, Ruby

  • Brian: Psychic, Attack: 100, Defence: 50, Speed: 80, Pain, Fireball, Watergun
  • Elemon1: Psychic, Attack: 100, Defence: 50, Speed: 80, Fireball, Watergun, Vine
  • Elemon2: Psychic, Attack: 100, Defence: 50, Speed: 80, Fireball, Watergun, Vine
TEAM_SPEC = "InsideYourHead"+
            "|Brian:1:100:50:80:3:6:9"+
            "|Elemon1:1:100:50:80:6:9:12"+
            "|Elemon2:1:100:50:80:6:9:12"

def parse_battle_state request
    request.map do |team_state|
        state = {}
        parts = team_state.split '|'
        state[:active] = parts.shift.split(':')[1].to_i
        state[:monsters] = parts.map do |monster_state|
            monster = {}
            parts = monster_state.split(':')
            monster[:name] = parts[0]
            monster[:hp] = parts[5].to_i
            monster[:type] = parts[6].to_i
            monster
        end
        state
    end
end

request = ARGV[0].split '#'
case request.shift
when 'T'
    puts TEAM_SPEC
when 'C'
    battle_state = parse_battle_state request
    my_state = battle_state[0]
    puts my_state[:monsters].find_index {|monster| monster[:hp] > 0}
when 'A'
    battle_state = parse_battle_state request
    my_state, their_state = *battle_state
    my_monster = my_state[:monsters][my_state[:active]]
    their_monster = their_state[:monsters][their_state[:active]]
    puts [1,0,1,2,0][their_monster[:type]]
when 'B'
    puts '0:0:0'
end

Run with

ruby InsideYourHead.rb

I haven't tested this against Manu's bot yet, but it beats the other three. The team and monster names are pretty random... I might change them if I come up with something better

The strategy is pretty simple: attack! All three monsters only have pure attack moves, and they choose their move based on the opponent's monster's type.

I might experiment with throwing in a Heal later.