Example #1
0
    time_factories = 0
    unit_types = variables.unit_types
    info = variables.info

    #print('TIME LEFT', gc.get_time_left_ms())
    ##print("past karbonite gain",variables.past_karbonite_gain)

    try:
        for unit in variables.in_order_units:
            if gc.get_time_left_ms() < 250:
                break
            # respective unit types execute their own AI
            if unit.unit_type == unit_types["worker"]:
                try:
                    start_time = time.time()
                    worker.timestep(unit)
                    time_workers += (time.time() - start_time)

                except Exception as e:
                    print('Error:', e)
                    # use this to show where the error was
                    traceback.print_exc()
            elif unit.unit_type == unit_types["knight"]:
                #start_time = time.time()
                knight.timestep(unit)
                #time_knights+=(time.time()-start_time)
            elif unit.unit_type == unit_types["ranger"]:
                try:
                    start_time = time.time()
                    ranger.timestep(unit)
                    time_rangers += (time.time() - start_time)
Example #2
0
         num_mages += 1
     elif unit.unit_type == bc.UnitType.Healer:
         num_healers += 1
     elif unit.unit_type == bc.UnitType.Factory:
         num_factory += 1
     elif unit.unit_type == bc.UnitType.Rocket:
         num_rocket += 1
 info = [
     num_workers, num_knights, num_rangers, num_mages, num_healers,
     num_factory, num_rocket
 ]
 for unit in gc.my_units():
     # resepective unit types execute their own AI
     if unit.unit_type == bc.UnitType.Worker:
         worker.timestep(gc, unit, info, karbonite_locations,
                         locs_next_to_terrain, blueprinting_queue,
                         building_assignment, current_worker_roles)
     elif unit.unit_type == bc.UnitType.Knight:
         knight.timestep(gc, unit, info, knight_to_cluster,
                         seen_knights_ids, KNIGHT_CLUSTER_MIN)
     elif unit.unit_type == bc.UnitType.Ranger:
         ranger.timestep(gc, unit, info, last_turn_battle_locs,
                         next_turn_battle_locs, queued_paths,
                         ranger_roles)
     elif unit.unit_type == bc.UnitType.Mage:
         mage.timestep(gc, unit, info, last_turn_battle_locs,
                       next_turn_battle_locs, queued_paths)
     elif unit.unit_type == bc.UnitType.Healer:
         healer.timestep(gc, unit, info, last_turn_battle_locs)
     elif unit.unit_type == bc.UnitType.Factory:
         factory.timestep(gc,