<fname><initial>.py: 8 points
<CustomName>
Creatureconstructor | def __init__(self) |
fighting behavior | you decide |
color | you decide |
movement behavior | you decide |
character | you decide |
You will decide the behavior of the <CustomName>
class. The constructor must accept no parameters as shown above. The format for naming your class should be your first name followed by your last initial. For instance, Yeobie Squirrel’s class would be called YeobieS
in the file yeobies.py
.
Make sure that your DIY critter is distinct from the required critters for the lab. A good rule of thumb is that at least one of the fight
and get_move
methods needs to do something substantive and new. Part of your grade will be based upon writing creative and non-trivial behavior in your critter class. The following are some guidelines and hints about how to write an interesting critter.
Your critter’s fighting behavior may want to utilize the parameter sent to the fight()
method, opp_info
, which is of type CritterInfo
.
Extra
In addition to those mentioned in Part 4, there are some other methods available via the CritterInfo
class that you can make use of in your DIY critters:
get_pos()
– returns the critter’s (x,y) coordinateget_dimensions()
– returns the (width, height) of the current simulation worldget_neighbor(direction)
– is a method that, when called with a parameter representing one of the direction constants, returns the name of the class (not the display character) of the critter in that location (i.e., the location that is one space in the given direction of the current critter)For example, the code opp_info.get_neighbor(constants.NORTH)
would return the string “Sloth” if there is a Sloth
to the north of your opponent, and the string ‘.’ if there is no neighbor to the north.
You can make your critter return any character you like from its get_char()
method and any color you like from the get_color()
method. In fact, critters are asked what display color and character to use on each round of the simulation, so you can have a critter that displays itself differently over time. Keep in mind that the get_char()
character is also passed to other animals when they battle your critter; you may wish to strategize to try to fool other critters. If you’re at a loss for ideas, consider how you could use randomization to cause new and different critter behavior!
Your section will host a Critter tournament during lecture where your critters will face off with each other and the other standard critters. Your instructor will share your section’s Tournament rules with you. The winner of the tournament will gain fame and fortune! If you would like to opt out/in to the Tournament, refer to your instructor’s directions from lecture/Blackboard.
Reminder
Please remember to commit and push your changes!