Instruction
Perfect! Right now, our game will always last 10 rounds because we aren't decreasing the robots' lives. Let's change that.
In the actual game, robots lose lives when they are hit by a laser beam. We don't have laser beams implemented yet, so we'll assume that a robot loses one life whenever its opponent shoots a laser beam.
Exercise
Add the argument lives_left as the last argument of the act_robot() function and as the last argument of play_round() function.
- Inside the
act_robot()function, decrease the opponent's life by 1 whenever a robot shoots a laser beam. Use theget_opponent_name()function we've already prepared to determine which robot's lives to decrease. - Change the
play_round()function.- Start by invoking
act_robot()for robot A. Remember to pass the new argumentlives_lefttoact_robot()function. - Robot A could have killed robot B in the previous step, so check if robot B has any lives left. If it does, perform
act_robot()for robot B.
- Start by invoking
Stuck? Here's a hint!
In point 1, decrease the opponent's life in the following way:
lives_left[get_opponent_name(robot)] -= 1
In point 2b, use the following code:
if lives_left['B'] > 0: act_robot(robot_b, lives_left)



