Robot Rumble ALPHA
discord
try it!
boards
tutorial
docs
login
/
signup
# swarm_bot V1 # replacement for hitman_bot # with bug fixes and more advanved botnet targets = {} current_state = None def get_area_status(pos): area = [ pos + Direction.North.to_coords, pos + Direction.East.to_coords, pos + Direction.South.to_coords, pos + Direction.West.to_coords, ] value = 0 for i in area: if current_state.obj_by_coords(i): if current_state.obj_by_coords(i).team == current_state.our_team: value += 1 elif current_state.obj_by_coords(i).team == current_state.other_team: value -= 1 return value def lowest_effort(iterator, pos): lowest_effo = MAP_SIZE ** 2 lowest_unit = None for x in iterator: distance = x.coords.walking_distance_to(pos) area = get_area_status(x.coords) effort = distance - (4 - area) if effort < lowest_effo: lowest_effo = effort lowest_unit = x return lowest_unit def get_aviable_position(pos): area = [ pos + Direction.North.to_coords, pos + Direction.East.to_coords, pos + Direction.South.to_coords, pos + Direction.West.to_coords, ] available = pos for i in area: if not current_state.obj_by_coords(i): if available == pos: available = [] available.append(i) if available != pos and len(available) > 1: lowest_effo = MAP_SIZE ** 2 lowest_unit = None for x in available: effort = x.distance_to(pos) if effort < lowest_effo: lowest_effo = effort lowest_unit = x available = lowest_unit elif type(available) == list: available = available[0] return available def init_turn(state): global target, current_state current_state = state our_team = state.objs_by_team(state.our_team) other_team = state.objs_by_team(state.other_team) for x in our_team: targets[x.id] = lowest_effort(other_team, x.coords) def robot(state, unit): target = targets[unit.id] direction = unit.coords.direction_to(target.coords) if unit.coords.walking_distance_to(target.coords) > 1: if state.obj_by_coords(unit.coords + direction.to_coords): if state.obj_by_coords(unit.coords + direction.to_coords).team == state.our_team: return Action.move(unit.coords.direction_to(get_aviable_position(target.coords))) else: return Action.attack(direction) else: return Action.move(direction) else: if state.obj_by_coords(unit.coords + direction.to_coords): if state.obj_by_coords(unit.coords + direction.to_coords).team == state.our_team: return None else: return Action.attack(direction)
Made with <3 by Anton and Noa
github org