Agent_25

Pitbull

  • 18.0average EPS
  • 18.0last EPS
Total Ranking
Ranking 1
Tournaments
Tournament 3
Level
Clone_war
Clone War

Tournaments

Tournament

Date: 8 Oct. 2012

  • 7agents
  • 5games
Winner
Agent_25 18.0
Agent
Agent_25 18.0
Tournament Rank
Ranking 1
Tournament

Date: 26 Aug. 2012

  • 7agents
  • 5games
Winner
Agent_25 18.4
Agent
Agent_25 18.4
Tournament Rank
Ranking 1
Tournament

Date: 7 Jul. 2012

  • 7agents
  • 5games
Winner
Agent_24 18.8
Agent
Agent_25 17.6
Tournament Rank
Ranking 2

Source

Licence
Source Code
module ScorpionKing

  class Pitbull < Tournament::Agent

    attr_accessor :enemies, :prey

    def after_start
      @enemies = []
      @enemy_size = 2.0/3.0
    end

    def think
      each_population do |population|
        @current = population
        begin
          been_attacked?
          @view = @current.look_around
          if field = hunted_prey || found_enemy
            hunting = true
            @current.move_to field
          elsif field = no_enemie
            hunting = false
            @current.split field
          else field = best_resource
            hunting = false
            @current.move_to field
          end
        end while(hunting)
      end
    end

    def no_enemie
      if @view.all?{|f| f.has_no_population? || !@enemies.include?(f.agent) }
        best_resource
      end
    end

    # goes the the biggest free resource
    def best_resource
      @view.select{|f| f.has_no_population? || myfield?(f) }.max_by{|f| f.resource}
    end

    def found_enemy
      if found_on_field = @view.select do |f|
          f.has_population? && @enemies.include?(f.agent) && @current.size * @enemy_size > f.population
        end.min_by do |f|
          f.population
        end
        @prey = found_on_field.agent
        info "found enemy #{@prey}, hunt begins"
        found_on_field
      end
    end

    def hunted_prey
      if @prey
        if hunted_prey = @view.find do|f|
            f.has_population? && f.agent == @prey && @current.size * @enemy_size > f.population
          end
          info "hunting down #{hunted_prey.agent}"
          hunted_prey
        else
          info "prey #{prey} lost or too big"
          nil
        end
      end
    end

    def been_attacked?
      each_event do |event|
        if event.instance_of? AttackedEvent
          unless @enemies.include? event.attacker
            @enemies << event.attacker
            info "keep in mind enemy #{event.attacker}"
          end
        end
      end
    end

    def myfield? field
      field.x == 0 && field.y == 0
    end

  end

end

Administrator

Change Agent State

on state accepted
Back to agent list