battlecode / battlehack20

🐍
https://bh2020.battlecode.org
GNU General Public License v3.0
12 stars 3 forks source link

Communication via addition to Team #133

Open cooljoseph1 opened 4 years ago

cooljoseph1 commented 4 years ago

You can add values to Team and use it for communication. E.g., the overlord can initially set Team.RUSH = False and later change it to Team.RUSH = True and the pawns can detect it.

cooljoseph1 commented 4 years ago

You can do the same thing by editing RobotType as well.

cooljoseph1 commented 4 years ago

Here's some sample code:

#bot.py
x = 0

def turn():
    global x
    x += 1
    board_size = get_board_size()
    team = get_team()
    opp_team = Team.WHITE if team == Team.BLACK else team.BLACK
    robottype = get_type()

    if robottype == RobotType.OVERLORD:
        RobotType.RUSH = True if x > 10 else False
        if team == Team.WHITE:
            index = 0
        else:
            index = board_size - 1

        for i in range(board_size):
            if not check_space(index, i):
                spawn(index, i)
                break

    else:
        log(str(RobotType.RUSH))
arvid220u commented 4 years ago

omg nice