#ifndef AVOIDANCEH #define AVOIDANCEH #include #include "wabbit.h" //a motion class that ranks its 8 possible moves based on collision avoidance //with an object with a character specified in the constructor. //used with the wall character (#) by the game, objects avoid picking moves //that would run them into walls class avoidance: protected virtual wabbit { char avoidChar; protected: //because vision_avoidance will be derived from this and needs access virtual void decide(int *dx, int *dy) const; virtual void getInitialDirection(int *dx, int *dy) const { //defaults to brownian selection, derived types can use vision *dx = rand() % 3 - 1; *dy = rand() % 3 - 1; } public: avoidance(game *initial_g, unsigned initial_x, unsigned initial_y, char initial_c, char initial_avoid) : wabbit(initial_g, initial_x, initial_y, initial_c), avoidChar(initial_avoid) {} }; #endif