Robot Rumble ALPHA
discord
try it!
boards
tutorial
docs
login
/
signup
# hitman_bot V1 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) health = x.health area = get_area_status(x.coords) effort = distance - (0.2 * (5 - health)) - (0.2 * (4 - area)) if effort < lowest_effo: lowest_effo = x.coords.walking_distance_to(pos) lowest_unit = x return lowest_unit 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.distance_to(target.coords) > 1: return Action.move(direction) else: 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