MCS 275 Spring 2022
Emily Dumas
Finish our robot simulation class hierarchy
Discuss more OOP theory & practice
PatrolBot
walks back and forth.WanderBot
walks about randomly.DestructBot
sits in one place for a while and then self-destructs.Attributes declared in the class definition, outside of any method, are class attributes.
Class attributes are shared by every instance of the class. Often used for constants.
Contrast with the instance attributes we have used thus far (e.g. self.x = 1
in constructor) which exist separately for each instance.
Beyond adding more robot types, how might me improve or extend the simulation?
Might create a class Arena
that manages the list of bots and the space in which they move. Would have a single .update()
method that updates all bots.
Each bot would know what Arena
it is in, and could call methods of Arena
to interrogate surroundings (e.g. avoid collision, seek other bots, ...)