예제 #1
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()
    random_directions = utility.random_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 and robot.me.turn < constants.pilgrim_will_scavenge_closeby_mines_before_turns:
        for direction in random_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 random_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
예제 #2
0
def preacher_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.random_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])
예제 #3
0
def church_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.random_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])
    robot.log("No space to build units anymore for churches")
    return None
예제 #4
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.random_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])
예제 #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.random_cells_around()

    prophet_attack_aggr_mode = combat_module.give_military_command(robot)
    if prophet_attack_aggr_mode != None:
        return prophet_attack_aggr_mode

    if utility.fuel_less_check(robot):
        return None

    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])