Robot Rumble ALPHA
discord
try it!
boards
tutorial
docs
login
/
signup
import random import math def printState(state): print({"turn": state.turn, "our_team": our_team, "obj_by_id": obj_by_id, }) def printUnit(unit): print({"id": unit.id, "coords": unit.coords, "obj_type": unit.obj_type, "team": unit.team, "health": unit.health}) def robot(state, unit): printUnit(unit) dist_to_enemy, enemy = find_nearest_enemy(state, unit.coords, unit.team) if dist_to_enemy == 1: return Action.attack(unit.coords.direction_to(enemy.coords)) else: return Action.move(unit.coords.direction_to(enemy.coords)) def find_nearest_enemy(state, coord, my_team): enemies = state.objs_by_team(my_team.opposite) distances_to_enemies = {enemy:coord.walking_distance_to(enemy.coords) for enemy in enemies} nearest_enemy = min(distances_to_enemies, key=distances_to_enemies.get) return (coord.walking_distance_to(nearest_enemy.coords), nearest_enemy)
Made with <3 by Anton and Noa
github org