What will make or break the game are the enhancements. Again, it is recommended that you start with the core described above, perhaps with only two or three weapons, get that working, and then proceed to enhance the program. The first step would be to expand the armory (i.e., the choices of weapons). Other ideas include randomizing the win/lose messages so that a certain weapon does not always generate the same message. One way to do that is as follows for each weapon:
m = random.randrange(3) if m == 0: print( “You won!” ) elif m == 1: print( “The rabbit is defeated!” ) else: print( “The rabbit was no match for you!” )
This technique will work but there is a more efficient method utilizing tuples (see the Tuples exercise for a general explanation; the random integer would serve as the index into a tuple of messages thereby removing the need for the
if/elif structure for much more compact code).
Other ideas include awarding an extra life as well as points for a particularly unlikely weapon, removing points as well as a life if the player loses on a “sure thing” weapon (i.e., The Holy Hand Grenade of Antioch) or preventing the player from using a certain weapon too many times (a variable would need to be added to keep track of the number of times the weapon was used). A popular add-on is the “extra life”. At the end of the loop, the score could be compared to a preset value (say, 5000 points) and an extra life added if that level is exceeded. This is somewhat trickier that it appears to be at first. A more interesting variant is the idea of adding lives for every “so many” points, such as a new life every 5000 points. There are a couple of different ways to do this but this also is not as simple as it at first appears.
For the more adventurous, advanced scores could expand the weapons menu or even introduce a new level, such as battling the Black Knight at the bridge or trying to escape from the Castle Anthrax. Different levels can be thought of as new loops added after the first loop (not within).
Take your time with the enhancement and try to make something that you and your friends might find enjoyable.