Example #1
0
                                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,
                                 unit,
                                 info,
                                 building_assignment,
                                 mining_rate=3 *
                                 len(current_worker_roles["miner"]))
            elif unit.unit_type == bc.UnitType.Rocket:
                rocket.timestep(gc, unit, info)

        ## Reset knight turn clusters
        seen_knights_ids = set()

    except Exception as e:
        print('Error:', e)
        # use this to show where the error was
        traceback.print_exc()

    # send the actions we've performed, and wait for our next turn.
    gc.next_turn()

    # these lines are not strictly necessary, but it helps make the logs make more sense.
    # it forces everything we've written this turn to be written to the manager.
    sys.stdout.flush()
Example #2
0
                        variables.ranger_roles["sniper"].remove(ranger)

                    traceback.print_exc()
            elif unit.unit_type == unit_types["mage"]:
                mage.timestep(unit)
            elif unit.unit_type == unit_types["healer"]:
                start_time = time.time()
                healer.timestep(unit)
                time_healers += (time.time() - start_time)
            elif unit.unit_type == unit_types["factory"]:
                start_time = time.time()
                factory.timestep(unit)
                time_factories += time.time() - start_time
            elif unit.unit_type == unit_types["rocket"]:
                #start_time = time.time()
                rocket.timestep(unit)
                #time_knights+=(time.time()-start_time)

        # if gc.planet() == bc.Planet.Mars:
        #     print('ranger roles: ', variables.ranger_roles)
        # if gc.planet() == bc.Planet.Earth:
        #     print("QUADRANTS: ", variables.quadrant_battle_locs)
        #     locs_correct = True
        #     for unit in gc.my_units():
        #         if unit.id in variables.unit_locations:
        #             loc_coords = (unit.location.map_location().x, unit.location.map_location().y)
        #             recorded = variables.unit_locations[unit.id]
        #             if loc_coords != recorded:
        #                 locs_correct = False
        #                 print('unit: ', unit)
        #                 print('coords recorded: ', recorded)
Example #3
0
                              next_turn_battle_locs, queued_paths)
            elif unit.unit_type == bc.UnitType.Healer:
                healer.timestep(gc, unit, info, last_turn_battle_locs,
                                constants)
            elif unit.unit_type == bc.UnitType.Factory:
                factory.timestep(gc,
                                 unit,
                                 info,
                                 building_assignment,
                                 last_turn_battle_locs,
                                 constants,
                                 mining_rate=3 *
                                 len(current_worker_roles["miner"]))
            elif unit.unit_type == bc.UnitType.Rocket:
                # print('hi')
                rocket.timestep(gc, unit, info, rocket_launch_times,
                                rocket_landing_sites)

        ## Reset knight turn clusters
        seen_knights_ids = set()

    except Exception as e:
        print('Error:', e)
        # use this to show where the error was
        traceback.print_exc()

    # send the actions we've performed, and wait for our next turn.
    gc.next_turn()

    # these lines are not strictly necessary, but it helps make the logs make more sense.
    # it forces everything we've written this turn to be written to the manager.
    sys.stdout.flush()