Robot Rumble ALPHA
discord
try it!
boards
tutorial
docs
login
/
signup
#import random #def robot(state, unit): # print(unit) # if random.randint(0,2) == 1: # js: if (Math.random() > 0.5) # return Action.move(Direction.East) # else: # return Action.attack(Direction.South) def robot(state, unit): enemies = state.objs_by_team(state.other_team) friends = state.objs_by_team(state.our_team) print(friends) #print(enemies) closest_enemy = min(enemies, key=lambda e: e.coords.distance_to(unit.coords) ) debug.inspect(closest_enemy) direction = unit.coords.direction_to(closest_enemy.coords) #print(direction) num_around = 0 for direction in [Direction.East, Direction.North, Direction.West, Direction.South]: obj = state.obj_by_coords(unit.coords + direction) if obj is not None and obj.obj_type == ObjType.Unit: num_around += 1 right_cell = state.obj_by_coords(unit.coords + Direction.East) # let north_cell = state.objByCoords(unit.coords.add(Direction.North)) # if (north_cell.team == state.other_team) { // it's an enemy debug.log("health :)", unit.health) #debug.log("right cell", right_cell) debug.log("num around", num_around) if right_cell is not None: # if (right_cell != null) debug.log("right cell is wall", right_cell.obj_type == ObjType.Terrain) if unit.coords.distance_to(closest_enemy.coords) == 1: # we're right next to them return Action.attack(direction) else: return Action.move(direction)
Made with <3 by Anton and Noa
github org