Exemple #1
0
 def __init__(self, agent):
     Behaviour.__init__(self, agent,
                        (), # behaviours
                        ("game_over", "life")) 
     # These are behaviour variables
     self.displayInfo = True
     self.bot = AIClient()
Exemple #2
0
    def __init__(self, agent):
        # initialise the behaviour by specifying that it provides the action
        # 'change_dir' and the senses 'see_cookie' and 'fail'. These have
        # to correspond to a method of the class.
       Behaviour.__init__(self, agent,
                           # Behaviours
                           # Zerg
                           ("spawn_drone", "spawn_overlord", "spawn_zerglings", 
                            "spawn_hydralisk", "spawn_mutalisk", "spawn_lurker",
                            "spawn_queen", "spawn_ultralisk", "spawn_defiler",
                            "spawn_devourer", "spawn_guardian", "spawn_scourge",
                            "spawn_infested_terran",
                            # Terran
							"train_SCV", "train_marine", "train_medic", 
                            "train_firebat", "train_battlecruiser", "train_ghost",
                            "train_goliath", "train_dropship", "train_science_vessel",
                            "train_siege_tank", "train_valkyrie", "train_vulture",
                            "train_wraith",
                            # Protoss
                            "train_probe", "train_zealot", "train_archon", 
                            "train_carrier", "train_corsair", "train_dark_archon",
                            "train_dark_templar", "train_dragoon", "train_templar",
                            "train_observer", "train_reaver", "train_scout",
                            "train_shuttle", "train_arbiter"
                            ), 
                           # Senses
                           ("larvae_count", "overlords_morphing")) # Zerg
Exemple #3
0
 def __init__(self, agent):
     """Initialises the PanicFlocking Behaviour.
     """
     # register the actions and senses
     Behaviour.__init__(self, agent,
                             ('set_panic_to_max', 'reduce_panic_level','move_to_target', 
                              'pick_flocking_target', 'panic_flock_move', 'flock_move', 
                              'dog_flock_with_sheep', 'avoid_predator_flock'),
                             ('neighbor_panic', 'predator_close', 'sheep_close', 'alone', 
                              'no_target'))
     # Initial behaviour state
     self.target = None
     self.alone_count = 0
     self.normal_jump = .7
     self.panic_level = 0
     # Set the inspectors
     self.registerInspectors(('PanicLevel', 'Target', 'AloneCount'))
     #  These are the default flocking parameters, set up for sheep.  The dogs override some of these in init_agent
     # maximum panic level
     self.PANIC_MAX = 10
     # standard panic decay per set
     self.PANIC_DECAY = 0.5
     # maximum 'allowed' distance to other agents
     self.MAXDISTANCE = 70
     # minimum distance after which we want to avoid the other agent
     self.MINDISTANCE = 5
     # people we can see, NeighbourhoodSize
     self.NHS = 50
Exemple #4
0
 def __init__(self, agent):
     Behaviour.__init__(self, agent,
                        ("stop_bot", "rotate", "big_rotate",
                         "move_player", "pickup_item", "walk"),
                        ("see_player", "see_item", "close_to_player",
                         "hit_object", "fail", "succeed", "is_rotating",
                         "is_walking", "is_stuck"))
     # senses fail and succeed
     self.fail = lambda : False
     self.succeed = lambda : True
Exemple #5
0
 def __init__(self, agent):
     Behaviour.__init__(
         self, agent,
         ("shoot_enemy_carrying_our_flag", "run_to_enemy_carrying_our_flag",
          "face_attacker", "set_attacker", "shoot_attacker"),
         ("see_enemy_with_our_flag", "our_flag_on_ground",
          "enemy_flag_on_ground", "incoming_projectile",
          "taken_damage_from_specific_player", "taken_damage",
          "is_responding_to_attack"))
     self.CombatInfo = CombatInfoClass()
Exemple #6
0
 def __init__(self, agent):
     # initialise the behaviour by specifying that it provides the action
     # 'change_dir' and the senses 'see_cookie' and 'fail'. These have
     # to correspond to a method of the class.
     Behaviour.__init__(self, agent,
                        ("start_collecting_gas", ), # behaviours
                        ("mineral_count", "gas_count", "supply_total",
                         "supply_used", "supply_available",
                         "predicted_supply_available", 
                         "drone_count",
                         "gas_saturated")) # senses
Exemple #7
0
 def __init__(self, agent):
     # initialise the behaviour by specifying that it provides the action
     # 'change_dir' and the senses 'see_cookie' and 'fail'. These have
     # to correspond to a method of the class.
     Behaviour.__init__(self, agent,
                        ("attack", "defend"), # behaviours
                        ("force_size", "is_attacking",
                         "hydralisk_count", "zealot_count",
                         "observer_count", "marine_medic_count",
                         "marine_medic_ratio"
                         )) # senses
 def __init__(self, agent):
     # initialise the behaviour by specifying that it provides the action
     # 'change_dir' and the senses 'see_cookie' and 'fail'. These have
     # to correspond to a method of the class.
     Behaviour.__init__(self, agent,
                        ("scout_drone",), # behaviours
                        ("found_enemy_base","scouting_drone", "is_enemy_zerg",
                         "is_enemy_protoss", "is_enemy_terran")) # senses
     # These are behaviour variables
     self.isDroneScouting = False
     self.isOverlordScouting = False
Exemple #9
0
 def __init__(self, agent):
     # initialise the behaviour by specifying that it provides the action
     # 'change_dir' and the senses 'see_cookie' and 'fail'. These have
     # to correspond to a method of the class.
     Behaviour.__init__(self, agent,
                        ('change_dir', ),
                        ('see_cookie', 'fail'))
     # These are behavior varibles
     # self.patience = 50
     self.base_dir = os.getcwd()
     self.cwd = self.base_dir
     self.cookie_name = 'cookie'
Exemple #10
0
 def __init__(self, agent):
     """Initialises the SheepHerding Behaviour.
     """
     self.succeed = lambda: 1
     Behaviour.__init__(
         self, agent,
         ('set_rest_spot', 'select_sheep_target', 'move_to_sheep_target',
          'move_to_rest_spot', 'rest', 'lose_target'),
         ('herd_too_wide', 'has_target', 'has_rest_spot', 'in_rest_spot',
          'succeed', 'rest_spot_old'))
     # set the initial state
     self.restSpot = None
     self.restTime = 0
     self.target = None
     # register inspectors
     self.registerInspectors(('Target', 'RestSpot'))
Exemple #11
0
 def __init__(self, agent):
     Behaviour.__init__(
         self, agent, ("walk_to_nav_point", "to_enemy_flag", "to_own_base",
                       "to_own_flag", "to_enemy_base", "inch",
                       "runto_medical_kit", "runto_weapon"),
         ("at_enemy_base", "at_own_base", "know_enemy_base_pos",
          "know_own_base_pos", "reachable_nav_point",
          "enemy_flag_reachable", "our_flag_reachable", "see_enemy",
          "see_reachable_medical_kit", "see_reachable_weapon",
          "too_close_for_path"))
     self.PosInfo = PositionsInfo()
     # set up useful constants
     self.PathHomeID = "PathHome"
     self.ReachPathHomeID = "ReachPathHome"
     self.PathToEnemyBaseID = "PathThere"
     self.ReachPathToEnemyBaseID = "ReachPathThere"
Exemple #12
0
 def __init__(self, agent):
     Behaviour.__init__(self, agent,
     # actions:
                ( 'startup', 'go2sat', 'adjustyaw', 'adjustpitch', 'go2fin1', 'go2panel', 'liftpanel',
                  'placepanel', 'pressbutton', 'liftcable', 'plugincable', 'go2fin2', 'go2stairs',
                  'climbstairs', 'opendoor', 'go2table', 'liftdetector', 'findleak', 'liftrepair',
                  'repairleak', 'go2fin3', 'alldone', 'retry','prep4Task1_1','phone_home', 'reharness',
                  'prep4Next' ),
     # senses:
                ('see_sat','fallen','timedout','retries_left','currentTaskIs','fail','succeed'))
     # These are behavior variables
     # self.agent = agent # Handled by the Base Class
     self.Timeout = 0
     self.retryCnt = 0
     self.startupTime = time.time()  #This should be wall time.  All others ROS time.
     self.curTask = -1
     self.stepCnt = 0
Exemple #13
0
 def __init__(self, agent):
     Behaviour.__init__(self, agent, (), ())
     # initially put the agent on all fields, as we might assign
     # the attribute self.fields later
     OrientedEntity.__init__(self, agent.getWorld().sim)
     # add controller to control the agent
     self._control = _MASONControl(self.agent)
     # sets the MASON random number generator
     self._setMASONRNG(self.agent.getWorld().sim)
     # default portrayal: white compass of size 3
     self._portrayal = OrientedPortrayal2D(
         SimplePortrayal2D(), 0, 3.0, Color.white,
         OrientedPortrayal2D.SHAPE_COMPASS)
     # standard attributes (should be changed after initialisation)
     self.fieldNames = None
     self.display = None
     self.name = 'noname'
Exemple #14
0
 def __init__(self, agent):
     # initialise the behaviour by specifying that it provides the action
     # 'change_dir' and the senses 'see_cookie' and 'fail'. These have
     # to correspond to a method of the class.
     Behaviour.__init__(self, agent, ('change_dir', ),
                        ('see_cookie', 'fail'))
     # These are behavior variables
     # self.patience = 50
     #self.base_dir = os.getcwd()
     #self.cwd = self.base_dir
     self.cookie_name = 'cookie'
     self.port = 0
     self.robot = None
     self.robotname = ""
     self.sonar = []
     self.pose = (0.0, 0.0, 0.0)
     self.others = []
     self.sensetm = time.time()
     self.sensedelay = 0.1
Exemple #15
0
 def assignAttributes(self, attributes):
     """Assigns the behaviour a set of attributes.
     
     This method picks out the attribute 'loc' and uses it to set to
     location of the agent. All other attributes are assigned by
     L{Behaviour.assignAttributes}. The location has to be given by
     C{MASON.loc = 100.0, 200.0}, where the value is to be given as a
     string ('100.0, 200.0' in this example), and the first value and the
     second value specify the x and the y coordinate respectively.
     
     @param attributes: dictionary of attributes to assign to behaviour.
     @type attributes: dictionary attribute_name -> value
     """
     # filter out 'loc' to set location of agent using setLoc
     if attributes.has_key('loc'):
         x, y = map(float, attributes['loc'].split(','))
         self.setLoc(Double2D(x, y))
         del attributes['loc']
     Behaviour.assignAttributes(self, attributes)
Exemple #16
0
    def __init__(self, agent, attributes=None):
        Behaviour.__init__(self, agent, (), (), attributes)
        # default connection values, use attributes to override
        self.ip = "127.0.0.1"
        self.port = "3000"
        self.botname = "BODbot"

        # Valid values for team are 0 and 1. If an invalid value is used gamebots
        # will alternate the team on which each new bot is placed.
        self.team = "-1"

        # all the rest is standard
        self.events = []  #things like hitting a wall
        self.conninfo = {}
        self.gameinfo = {}
        self.view_players = {}
        self.view_items = {}
        self.nav_points = {}
        self.botinfo = {}
        self.s_gameinfo = {}
        self.s_view_players = {}
        self.s_view_items = {}
        self.s_nav_points = {}
        self.s_botinfo = {}
        self.msg_log = []  # Temp Log for message received
        self.msg_log_max = 4096  # Max Temp Log size
        self.sent_msg_log = []  # Temp Log for messages sent
        self.sent_msg_log_max = 6  # Max Temp Log size
        self.hit_timestamp = 0  # Used to inhibit was_hit()
        self.thread_active = 0
        self.kill_connection = 0
        self.rotation_hist = []
        self.velocity_hist = []
        self.thread_active = 0
        self.conn_ready = 0
        self.conn_thread_id = None
Exemple #17
0
 def __init__(self, agent):
     Behaviour.__init__(
         self, agent, (),
         ("have_enemy_flag", "own_health_level", "are_armed", "ammo_amount",
          "armed_and_ammo"))  # "holding_enemy_flag was removed
Exemple #18
0
 def __init__(self, agent):
     # initialise the behaviour by specifying that it provides the action
     # 'change_dir' and the senses 'see_cookie' and 'fail'. These have
     # to correspond to a method of the class.
     Behaviour.__init__(self, agent,
                        # Behaviours
                        
                        # Zerg
                        ("upgrade_zergling_speed"    , "upgrade_hydralisk_speed",
                         "upgrade_hydralisk_range"   , "zerg_upgrade_flyer_carapace",
                         "zerg_upgrade_flyer_attacks", "upgrade_overlord_speed",
                         "zerg_upgrade_melee"        , "zerg_upgrade_ranged",
                         "zerg_upgrade_carapace"     , "upgrade_defiler_energy",
                         "upgrade_overlord_sight"    , "upgrade_queen_energy",
                         "upgrade_zergling_atk_spd"  , "upgrade_ultralisk_armor",
                         "upgrade_ultralisk_speed"   , "research_ensnare",                      
                         "research_lurker_aspect"    , "research_broodlings",
                         "research_burrow"           , "research_overlord_transport",
                         "research_plague"           , "research_consume",
                        
                         # Terran
                         "upgrade_marine_range"      , "upgrade_medic_energy",
                         "upgrade_vehicle_weapons"   , "upgrade_vehicle_armor",
                         "upgrade_ship_weapons"      , "upgrade_ship_armor",
                         "upgrade_wraith_energy"     , "upgrade_ghost_sight",
                         "upgrade_ghost_energy"      , "upgrade_infantry_weapons",
                         "upgrade_infantry_armor"    , "upgrade_vulture_speed",
                         "upgrade_goliath_range"     , "upgrade_battlecruiser_energy",
                         "upgrade_sci_vessel_energy" , "research_stimpack",
                         "research_restoration"      , "research_flare",
                         "research_wraith_cloak"     , "research_ghost_cloak",
                         "research_lockdown"         , "research_siege_mode",
                         "research_spider_mines"     , "research_yamato_gun",
                         "research_emp"              , "research_irradiate",     
                        
                         # Protoss
                         "upgrade_ground_weapons"    , "upgrade_ground_armor",
                         "upgrade_arbiter_energy"    , "upgrade_zealot_speed",
                         "upgrade_air_weapons"       , "upgrade_air_armor",
                         "upgrade_dragoon_range"     , "upgrade_scout_sight",
                         "upgrade_scout_speed"       , "upgrade_carrier_capacity",
                         "upgrade_corsair_energy"    , "upgrade_plasma_shields",
                         "upgrade_observer_speed"    , "upgrade_observer_sight",
                         "upgrade_reaver_capacity"   , "upgrade_scarab_damage",
                         "upgrade_shuttle_speed"     , "upgrade_dark_archon_energy",
                         "upgrade_templar_energy"    , "research_recall",
                         "research_stasis_field"     , "research_disruption_web",
                         "research_hallucination"    , "research_psionic_storm",
                         "research_maelstrom"        , "research_mind_control",
                          ), 
                       
                        # Senses
                        
                        # Zerg
                        ("has_zergling_speed"            , "has_hydralisk_speed",                 
                         "has_hydralisk_range"           , "has_overlord_speed",
                         "zerg_flyer_attack_level"       , "zerg_flyer_carapace_level",                             
                         "zerg_melee_level"              , "currently_upgrading_melee",
                         "zerg_ranged_level"             , "currently_upgrading_ranged",
                         "zerg_carapace_level"           , "currently_upgrading_carapace",                            
                         "has_completed_lurker_aspect"   , "has_lurker_aspect", 
                         "has_defiler_energy"            , "has_overlord_sight",
                         "has_queen_energy"              , "has_zergling_atk_spd",
                         "has_ultralisk_armor"           , "has_ultralisk_speed", 
                         "has_ensnare"                   , "has_broodlings", 
                         "has_burrow"                    , "has_overlord_transport", 
                         "has_plague"                    , "has_consume",                            
                         
                         # Terran
                         "has_marine_range"	            , "has_medic_energy",   
                         "vehicle_weapons_level"	        , "vehicle_armor_level",    
                         "ship_weapons_level"	        , "ship_armor_level",   
                         "has_wraith_energy"	            , "has_ghost_sight", 
                         "has_ghost_energy"	            , "infantry_weapons_level",  
                         "infantry_armor_level"          , "has_vulture_speed",  
                         "has_goliath_range"             , "has_battlecruiser_energy", 
                         "has_sci_vessel_energy"         , "has_stimpack",      
                         "has_restoration"               , "has_flare",   
                         "has_wraith_cloak"              , "has_ghost_cloak",  
                         "has_lockdown"                  , "has_siege_mode", 
                         "has_spider_mines"              , "has_yamato_gun",   
                         "has_emp"                       , "has_irradiate",                   
                                        
                         
                         # Protoss
                         "ground_weapons_level"          , "ground_armor_level",            
                         "has_arbiter_energy"            , "has_zealot_speed",              
                         "air_weapons_level"	            , "air_armor_level",               
                         "has_dragoon_range"	            , "has_scout_sight",               
                         "has_scout_speed"	            , "has_carrier_capacity",          
                         "has_corsair_energy"	        , "plasma_shields_level",          
                         "has_observer_speed"	        , "has_observer_sight",            
                         "has_reaver_capacity"	        , "has_scarab_damage",             
                         "has_shuttle_speed"	            , "has_dark_archon_energy",        
                         "has_templar_energy"	        , "has_recall",                    
                         "has_stasis_field"	            , "has_disruption_web",            
                         "has_hallucination"	            , "has_psionic_storm",             
                         "has_maelstrom"	                , "has_mind_control",              
                         ))
     
     # These are behaviour variables
     
     '''
Exemple #19
0
    def __init__(self, agent):
        # initialise the behaviour by specifying that it provides the action
        # 'change_dir' and the senses 'see_cookie' and 'fail'. These have
        # to correspond to a method of the class.
        Behaviour.__init__(self, agent,
                            # Behaviours
                           
                            # General
                            ("build_extractor"          , "send_drone_expansion", 
                            "build_expansion_hatchery"  ,
                           
                            # Zerg
                            "build_spawning_pool"   , "build_macro_hatchery",
                            "build_hydralisk_den"   , "build_evolution_chamber", 
                            "build_creep_colony"    , "build_spire",
                            "build_defiler_mound"   , "build_queens_nest",
                            "build_ultralisk_cavern", "build_nydus_canal_start",
                            "build_nydus_canal_end" , "upgrade_to_greater_spire",                        
                            "upgrade_to_lair"       , "upgrade_to_hive",
                            "upgrade_to_sunken"     , "upgrade_to_spore",
                            "infest_command_center" , # this one may get moved
                            
                            # Terran
                            "build_supply_depot"    , "build_barracks",
                            "build_academy"         , "build_armory",
                            "build_bunker"          , "build_engineering_bay",
                            "build_factory"         , "build_missle_turret",
                            "build_science_facility", "build_starport",
                            "addon_comsat"          , "addon_nuke_silo", 
                            "addon_control_tower"   , "addon_covert_ops",
                            "addon_machine_shop"    , "addon_physics_lab",
                              
                            # Protoss
                            "build_pylon"               , "build_gateway", 
                            "build_arbiter_tribunal"    , "build_citadel",
                            "build_cybernetics_core"    , "build_fleet_beacon",
                            "build_observatory"         , "build_photon_cannon",
                            "build_robotics_facility"   , "build_robotics_support_bay",
                            "build_shield_battery"      , "build_stargate",
                            "build_templar_archive"     , "build_forge"
                            ),
                            #Senses

                            #General
                            ("has_completed_extractor", "has_extractor", 
                            "check_drone_ready_expand", "expansion_count",
                            "all_extractors_completed", "extractor_count", 
                            "has_extractor_saturation", # Note: This sense can be inaccurate on some maps as
                                                        # it assumes all bases have gas which isn't always true
                           
                            # Zerg
                            "has_spawning_pool"     , "has_completed_spawning_pool", 
                            "has_hydralisk_den"     , "has_completed_hydralisk_den",
                            "has_spire"             , "has_completed_spire",
                            "has_lair"              , "has_completed_lair",
                            "has_hive"              , "has_completed_hive",
                            "hatchery_count"        , 
                            "colony_count"          , "creep_colony_count" ,
                            "sunken_count"          , "spore_count",                
                            "evo_chamber_count"     , "completed_evo_chamber_count",
                            "has_defiler_mound"     , "has_completed_defiler_mound",
                            "has_queens_nest"       , "has_completed_queens_nest",
                            "has_ultralisk_cavern"  , "has_completed_ultralisk_cavern",
                            "has_greater_spire"     , "has_completed_greater_spire",
                            
                            # Terran
                            "barracks_count"        , "completed_barracks_count",
                            "academy_count"         , "completed_academy_count", "have_free_academy",
                            "armory_count"          , "completed_armory_count",
                            "bunker_count"          , "completed_bunker_count",
                            "engineering_bay_count" , "completed_engineering_bay_count", "have_free_bay",
                            "factory_count"         , "completed_factory_count",
                            "missle_turret_count"   , "completed_missle_turret_count",
                            "science_facility_count", "completed_science_facility_count",
                            "starport_count"        , "completed_starport_count",
                            "comsat_count"          , "completed_comsat_count",
                            "nuke_silo_count"       , "completed_nuke_silo_count",
                            "control_tower_count"   , "completed_control_tower_count",
                            "covert_ops_count"      , "completed_covert_ops_count",
                            "machine_shop_count"    , "completed_machine_shop_count",
                            "physics_lab_count"     , "completed_physics_lab_count",
                            
                            # Protoss
                            "pylon_count"               , #completed pylons can be grokd from supply_count
                            "gateway_count"             , "completed_gateway_count", 
                            "forge_count"               , "completed_forge_count", "free_forge_count",
                            "arbiter_tribunal_count"    , "completed_arbiter_tribunal_count",
                            "citadel_count"             , "completed_citadel_count",
                            "cybernetics_core_count"    , "completed_cybernetics_core_count",
                            "fleet_beacon_count"        , "completed_fleet_beacon_count",
                            "observatory_count"         , "completed_observatory_count",
                            "photon_cannon_count"       , "completed_photon_cannon_count",
                            "robotics_facility_count"   , "completed_robotics_facility_count",
                            "robotics_support_bay_count", "completed_robotics_support_bay_count",
                            "shield_battery_count"      , "completed_shield_battery_count",
                            "stargate_count"            , "completed_stargate_count",
                            "templar_archive_count"     , "completed_templar_archive_count",
                            
                            ))