diy_critter1.py: 8 points
diy_critter2.py: 8 points
|fighting behavior||you decide|
|movement behavior||you decide|
You will decide the behavior of the
<YourName2> classes. The constructor for both classes must accept no parameters as shown above. Remember, the format for naming your class should be your first name followed by your last initial. For instance, Yeobie Squirrel’s first class would be called
YeobieS1 in the file
yeobies1.py, and its second critter would be called
YeobieS2 in the file
Make sure that your DIY critters are distinct from the required critters for the lab and also from each other. A good rule of thumb is that at least one of the
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 classes. 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
opp_info, which is of type
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 in your DIY critters:
get_pos()- returns the critter’s (x,y) coordinate
get_dimensions()- returns the (width, height) of the current simulation world
get_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)
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!