DIY Critter

<fname><initial>.py: 8 points

<YourName> Creature

constructordef __init__(self)
fighting behavioryou decide
coloryou decide
movement behavioryou decide
characteryou decide

You will decide the behavior of the <YourName> 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


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.


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) 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)

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.

Other Behavior

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!


Please remember to commit and push your changes!