Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions battlecode25/engine/game/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def process_end_of_turn(self):
paint_penalty += 2 * len(adjacent_allies)
self.add_paint(-paint_penalty)

if self.type.name == "TOWER":
if self.type.is_tower_type():
self.add_paint(self.type.paint_per_turn)
self.game.team_info.add_coins(self.type.money_per_turn)
self.game.team_info.add_coins(self.team, self.type.money_per_turn)
self.has_tower_area_attacked = False
self.has_tower_single_attacked = False

Expand Down
1 change: 1 addition & 0 deletions battlecode25/engine/game/robot_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def assert_can_attack(self, loc: MapLocation) -> None:
raise RobotError("Tower cannot use single tile attack more than once per turn.")

def can_attack(self, loc: MapLocation) -> bool:
# self.assert_can_attack(loc)
try:
self.assert_can_attack(loc)
return True
Expand Down
65 changes: 65 additions & 0 deletions players/davidbot/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import random

from battlecode25.stubs import *

# This is an example bot written by the developers!
# Use this to help write your own code, or run it against your bot to see how well you can do!

directions = [
Direction.NORTH,
Direction.EAST,
Direction.SOUTH,
Direction.WEST,
Direction.NORTHEAST,
Direction.NORTHWEST,
Direction.SOUTHEAST,
Direction.SOUTHWEST
]

paint_towers = [UnitType.LEVEL_ONE_PAINT_TOWER, UnitType.LEVEL_TWO_PAINT_TOWER, UnitType.LEVEL_THREE_PAINT_TOWER]

def turn():
loc = get_location()

if can_upgrade_tower(loc):
upgrade_tower(loc)

if get_type().is_tower_type():
spawn_loc = loc.add(directions[random.randint(0, 3)])
if can_build_robot(UnitType.SPLASHER, spawn_loc):
build_robot(UnitType.SPLASHER, spawn_loc)

danger = sense_nearby_robots()
# log("danger is")
# log([(r.get_location().x, r.get_location().y) for r in danger])
# log()
for robot in danger:
if can_attack(robot.get_location()):
# log("BOOM")
attack(robot.get_location())

else:
dir = directions[random.randint(0, 3)]
if can_move(dir):
move(dir)
attack_loc = get_location().add(dir)
if can_attack(attack_loc):
attack(attack_loc)





# loc = get_location()
# log("Location is")
# log(loc)
# for i in range(9, 14):
# for j in range(9, 14):
# log(can_sense_location(MapLocation(i, j)))
# # log(can_sense_location(MapLocation(-1, -2)))
# # log(can_sense_location(MapLocation(-1, 20)))
# # log(can_sense_location(MapLocation(15, -2)))
# # log(can_sense_location(MapLocation(35, 35)))
# # log(can_sense_location(MapLocation(30, 29)))
# # log(can_sense_location(MapLocation(29, 25)))
# log()
62 changes: 47 additions & 15 deletions players/examplefuncsplayer/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,55 @@
Direction.WEST,
]

# def turn():
# global turn_count
# turn_count += 1
# robot_type = random.randint(0, 2)
# spawn_loc = get_location().add(directions[random.randint(0, 3)])
# if robot_type == 0 and can_spawn(RobotType.MOPPER, spawn_loc):
# spawn(RobotType.MOPPER, spawn_loc)
# if robot_type == 1 and can_spawn(RobotType.SPLASHER, spawn_loc):
# spawn(RobotType.SPLASHER, spawn_loc)
# if robot_type == 2 and can_spawn(RobotType.SOLDIER, spawn_loc):
# spawn(RobotType.SOLDIER, spawn_loc)
# att_dir = get_location().add(directions[random.randint(0, 3)])
# if can_attack(att_dir):
# attack(att_dir, use_secondary_color=False)
# dir = directions[random.randint(0, 3)]
# if can_move(dir):
# move(dir)

def turn():

"""
MUST be defined for robot to run
This function will be called at the beginning of every turn and should contain the bulk of your robot commands
"""
# direction = directions[random.randint(0, 3)]
# if can_move(direction):
# move(direction)

# loc = get_location()
# log(loc)

# pass

# if can_move(Direction.NORTH):
# move(Direction.NORTH)

global turn_count
turn_count += 1
robot_type = random.randint(0, 2)
spawn_loc = get_location().add(directions[random.randint(0, 3)])
if robot_type == 0 and can_build_robot(RobotType.MOPPER, spawn_loc):
build_robot(RobotType.MOPPER, spawn_loc)
if robot_type == 1 and can_build_robot(RobotType.SPLASHER, spawn_loc):
build_robot(RobotType.SPLASHER, spawn_loc)
if robot_type == 2 and can_build_robot(RobotType.SOLDIER, spawn_loc):
build_robot(RobotType.SOLDIER, spawn_loc)
att_dir = get_location().add(directions[random.randint(0, 3)])
if can_attack(att_dir):
attack(att_dir, use_secondary_color=False)
# if robot_type == 0 and can_spawn(RobotType.MOPPER, spawn_loc):
# spawn(RobotType.MOPPER, spawn_loc)
# if robot_type == 1 and can_spawn(RobotType.SPLASHER, spawn_loc):
# spawn(RobotType.SPLASHER, spawn_loc)
# if robot_type == 2 and can_spawn(RobotType.SOLDIER, spawn_loc):
# spawn(RobotType.SOLDIER, spawn_loc)
# att_dir = get_location().add(directions[random.randint(0, 3)])
# if can_attack(att_dir):
# attack(att_dir, use_secondary_color=False)
dir = directions[random.randint(0, 3)]
if can_move(dir):
move(dir)
Expand All @@ -43,10 +78,7 @@ def turn():
# # if can_move(direction):
# # move(direction)

# loc = get_location()
# log(loc)
# log(loc.add(Direction.NORTH))
# # loc = get_location()
# # log(loc)

# # log(get_round_num())
# # if can_move(Direction.NORTH):
# # move(Direction.NORTH)
# move(Direction.NORTH)