Robot Rumble ALPHA
discord
try it!
boards
tutorial
docs
login
/
signup
def inbounds(coords, direction): x, y = coords + direction if (y==1 or y==17) and (x<5 or x>13): return False if (y==2 or y==16) and (x<4 or x>14): return False if (y==3 or y==15) and (x<3 or x>15): return False if (y==4 or y==14) and (x<2 or x>16): return False return True def robot(state, unit): enemies = state.objs_by_team(state.other_team) closest_enemy = min(enemies, key=lambda e: e.coords.walking_distance_to(unit.coords) ) debug.inspect(closest_enemy) team_coords = [obj.coords for obj in state.objs_by_team(unit.team)] direction = unit.coords.direction_to(closest_enemy.coords) dist = unit.coords.walking_distance_to(closest_enemy.coords) debug.log('want to go', direction) while Coords(unit.coords.x + direction.to_coords.x, unit.coords.y + direction.to_coords.y) in team_coords or Coords(unit.coords.x + direction.to_coords.x, unit.coords.y + direction.to_coords.y).walking_distance_to(closest_enemy.coords) > dist or not inbounds(unit.coords, direction): direction = direction.rotate_cw dist = Coords(unit.coords.x + direction.to_coords.x, unit.coords.y + direction.to_coords.y).walking_distance_to(closest_enemy.coords) if unit.coords.distance_to(closest_enemy.coords) == 1: return Action.attack(direction) else: return Action.move(direction)
Made with <3 by Anton and Noa
github org