コード例 #1
0
def pilgrim_full(robot):
    unit_castle = SPECS['CASTLE']
    unit_church = SPECS['CHURCH']

    pos_x = robot.me.x
    pos_y = robot.me.y
    carry_karb = robot.me.karbonite
    carry_fuel = robot.me.fuel

    karb_map = robot.get_karbonite_map()
    fuel_map = robot.get_fuel_map()
    passable_map = robot.get_passable_map()
    occupied_map = robot.get_visible_robot_map()
    directions = utility.cells_around()

    if karb_map[pos_y][pos_x] == 1 or fuel_map[pos_y][pos_x] == 1:
        friendly_units = vision.sort_visible_friendlies_by_distance(robot)
        if friendly_units:
            for f_unit in friendly_units:
                dx = f_unit.x - pos_x
                dy = f_unit.y - pos_y
                if f_unit.unit == unit_church or f_unit.unit == unit_castle:
                    if (dy, dx in directions) and abs(dx) <= 1 and abs(dy) <= 1 and (robot.get_visible_robot_map()[pos_y + dy][pos_x + dx] > 0):
                        return robot.give(dx, dy, carry_karb, carry_fuel)

        for direction in directions:
            if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],  pos_y + direction[0])) and (karb_map[pos_y + direction[0]][pos_x + direction[1]] != 1 or fuel_map[pos_y + direction[0]][pos_x + direction[1]] != 1) and passable_map[pos_y + direction[0]][pos_x + direction[1]] == 1:
                if robot.karbonite > 50 and robot.fuel > 200:
                    robot.log("Drop a church like it's hot")
                    return robot.build_unit(unit_church, direction[1], direction[0])
コード例 #2
0
def pilgrim_full(robot):
    unit_church = SPECS['CHURCH']

    pos_x = robot.me.x
    pos_y = robot.me.y
    carry_karb = robot.me.karbonite
    carry_fuel = robot.me.fuel

    karb_map = robot.get_karbonite_map()
    fuel_map = robot.get_fuel_map()
    passable_map = robot.get_passable_map()
    occupied_map = robot.get_visible_robot_map()
    directions = utility.cells_around()

    if karb_map[pos_y][pos_x] == 1 or fuel_map[pos_y][pos_x] == 1:
        friendly_units = vision.sort_visible_friendlies_by_distance(robot)
        if friendly_units:
            for f_unit in friendly_units:
                dx = f_unit.x - pos_x
                dy = f_unit.y - pos_y
                if f_unit.unit == unit_church and abs(dx) <= 1 and abs(dy) <= 1 and utility.is_cell_occupied(occupied_map, f_unit.x, f_unit.y):
                    robot.log("Giving church " + str(f_unit.id) + " " + str(carry_karb) + " karbonite and " + str(carry_fuel) + " fuel.")
                    robot.log(str(f_unit))
                    robot.log(str(robot.me))
                    robot.log(str((dx, dy)))
                    # if utility.is_cell_occupied(occupied_map, pos_x + f_unit.x - pos_x, pos_y + f_unit.y - pos_y):
                    #     robot.log("Exists")
                    return robot.give(dx, dy, carry_karb, carry_fuel)
        
        for direction in directions:
            if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],  pos_y + direction[0])) and (karb_map[pos_y + direction[0]][pos_x + direction[1]] != 1 or fuel_map[pos_y + direction[0]][pos_x + direction[1]] != 1) and passable_map[pos_y + direction[0]][pos_x + direction[1]] == 1:
                if robot.karbonite > 50 and robot.fuel > 200:
                    robot.log("Drop a church like it's hot")
                    return robot.build_unit(unit_church, direction[1], direction[0])
コード例 #3
0
def pilgrim_move(robot):
    if robot.fuel <= 2 :
        return 0
    pos_x = robot.me.x
    pos_y = robot.me.y

    passable_map = robot.get_passable_map()
    karb_map = robot.get_karbonite_map()
    fuel_map = robot.get_fuel_map()
    occupied_map = robot.get_visible_robot_map()
    directions = utility.cells_around()
    # May change for impossible resources
    
    for direction in directions:
        if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],  pos_y + direction[0])) and (karb_map[pos_y + direction[0]][pos_x + direction[1]] == 1 or fuel_map[pos_y + direction[0]][pos_x + direction[1]] == 1):
            return robot.move(direction[1], direction[0])
    # Just move
    # move_to = move_to_nearest_mine(robot)
    # if move_to != None:
    #     robot.log("check")
    #     new_pos_x, new_pos_y = move_to
    #     return robot.move(new_pos_x - pos_x, new_pos_y - pos_y)
    
    for direction in directions:
        if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],  pos_y + direction[0])) and passable_map[pos_y + direction[0]][pos_x + direction[1]] == 1:
            return robot.move(direction[1], direction[0])

    return 0
コード例 #4
0
def castle_build(robot, unit_type):
    pos_x = robot.me.x
    pos_y = robot.me.y
    occupied_map = robot.get_visible_robot_map()
    passable_map = robot.get_passable_map()
    directions = utility.cells_around()
    for direction in directions:
        if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],  pos_y + direction[0])) and passable_map[pos_y + direction[0]][pos_x + direction[1]] == 1:
            return robot.build_unit(unit_type, direction[1], direction[0])
コード例 #5
0
def prophet_move(robot):
    pos_x = robot.me.x
    pos_y = robot.me.y
    passable_map = robot.get_passable_map()
    occupied_map = robot.get_visible_robot_map()
    directions = utility.cells_around()

    for direction in directions:
        if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],  pos_y + direction[0])) and passable_map[pos_y + direction[0]][pos_x + direction[1]] == 1:
            return robot.move(direction[1], direction[0])
コード例 #6
0
def crusader_move(robot):
    pos_x = robot.me.x
    pos_y = robot.me.y
    passable_map = robot.get_passable_map()
    occupied_map = robot.get_visible_robot_map()
    directions = utility.cells_around()

    crusader_is_attacking_or_aggressive_moving = combat_module.give_military_command(
        robot)
    if crusader_is_attacking_or_aggressive_moving != None:
        return crusader_is_attacking_or_aggressive_moving
    for direction in directions:
        if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],
                                         pos_y + direction[0])
            ) and passable_map[pos_y + direction[0]][pos_x +
                                                     direction[1]] == 1:
            return robot.move(direction[1], direction[0])
コード例 #7
0
def pilgrim_full(robot):
    pos_x = robot.me.x
    pos_y = robot.me.y
    carry_karb = robot.me.karbonite
    carry_fuel = robot.me.fuel

    karb_map = robot.get_karbonite_map()
    fuel_map = robot.get_fuel_map()
    passable_map = robot.get_passable_map()
    occupied_map = robot.get_visible_robot_map()
    directions = utility.cells_around()

    if karb_map[pos_y][pos_x] == 1 or fuel_map[pos_y][pos_x] == 1:
        _, friendly_units = vision.sort_visible_friendlies_by_distance(robot)
        if friendly_units:
            for f_unit in friendly_units:
                dx = f_unit.x - pos_x
                dy = f_unit.y - pos_y
                if f_unit.unit == constants.unit_church or f_unit.unit == constants.unit_castle:
                    if (dy, dx in directions
                        ) and abs(dx) <= 1 and abs(dy) <= 1 and (
                            robot.get_visible_robot_map()[pos_y + dy][pos_x +
                                                                      dx] > 0):
                        robot.signal(0, 0)
                        return robot.give(dx, dy, carry_karb, carry_fuel)

    # TODO - Make churches not be built if castle is in vision range
    # TODO - If multiple mine spots in vision, try placing at proper place
    # FIXME - Don't put churches on resources
        for direction in directions:
            if (not utility.is_cell_occupied(
                    occupied_map, pos_x + direction[1], pos_y + direction[0]
            )) and (karb_map[pos_y + direction[0]][pos_x + direction[1]] != 1
                    or fuel_map[pos_y + direction[0]][pos_x + direction[1]] !=
                    1) and passable_map[pos_y +
                                        direction[0]][pos_x +
                                                      direction[1]] == 1:
                if robot.karbonite > 50 and robot.fuel > 200:
                    robot.log("Drop a church like it's hot")
                    robot.signal(0, 0)
                    return robot.build_unit(constants.unit_church,
                                            direction[1], direction[0])
コード例 #8
0
def pilgrim_move(robot, unit_signal):
    if robot.fuel <= 2:
        return 0
    pos_x = robot.me.x
    pos_y = robot.me.y

    passable_map = robot.get_passable_map()
    karb_map = robot.get_karbonite_map()
    fuel_map = robot.get_fuel_map()
    occupied_map = robot.get_visible_robot_map()
    directions = utility.cells_around()
    # May change for impossible resources

    # Capture and start mining any resource if more than 50 turns since creation and no mine
    # TODO - Improve this code snippet to mine, if in visible region and empty
    if robot.me.turn > constants.pilgrim_will_scavenge_closeby_mines_after_turns:
        for direction in directions:
            if (not utility.is_cell_occupied(
                    occupied_map, pos_x + direction[1], pos_y + direction[0])
                ) and (karb_map[pos_y + direction[0]][pos_x + direction[1]]
                       == 1
                       or fuel_map[pos_y + direction[0]][pos_x + direction[1]]
                       == 1):
                return robot.move(direction[1], direction[0])
    # Just move
    if unit_signal >= 6464:
        move_to = move_to_specified_mine(robot, unit_signal)
        if move_to != None:
            # robot.log("check")
            new_pos_x, new_pos_y = move_to
            return robot.move(new_pos_x - pos_x, new_pos_y - pos_y)

    # Random Movement when not enough time
    for direction in directions:
        if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],
                                         pos_y + direction[0])
            ) and passable_map[pos_y + direction[0]][pos_x +
                                                     direction[1]] == 1:
            return robot.move(direction[1], direction[0])

    return 0
コード例 #9
0
def pilgrim_move(robot):
    if robot.fuel <= 2 :
        return 0
    pos_x = robot.me.x
    pos_y = robot.me.y

    passable_map = robot.get_passable_map()
    karb_map = robot.get_karbonite_map()
    fuel_map = robot.get_fuel_map()
    occupied_map = robot.get_visible_robot_map()
    directions = utility.cells_around()
    # May change for impossible resources
    for direction in directions:
        if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],  pos_y + direction[0])) and (karb_map[pos_y + direction[0]][pos_x + direction[1]] == 1 or fuel_map[pos_y + direction[0]][pos_x + direction[1]] == 1):
            return robot.move(direction[1], direction[0])
    # Just move
    for direction in directions:
        if (not utility.is_cell_occupied(occupied_map, pos_x + direction[1],  pos_y + direction[0])) and passable_map[pos_y + direction[0]][pos_x + direction[1]] == 1:
            return robot.move(direction[1], direction[0])

    return 0