// Collection of useful information gathering routines // Definitions needed to ensure no collisions between team naming schemes #define Surround UN(Surround) #define BallDirection UN(BallDirection) #define GetInfo UN(GetInfo) // Things that can be next to you enum things {BALL=0, OPPONENT=1, TEAMATE=2, EMPTY=3, OUT=4}; // Compass directions enum directions {NW=0, N=1, NE=2, W=3, E=4, SW=5, S=6, SE=7}; // Global variables which will contain useful information when we're done int Surround[8]; // The eight squares around the player int BallDirection; // Direction of the Ball void GetInfo() { int i, j; // Get the contents of all of the surrounding squares in a // more useful format if (Content("NW","BALL")) Surround[NW] = BALL; else if (Content("NW","OPPONENT")) Surround[NW] = OPPONENT; else if (Content("NW","TEAMATE")) Surround[NW] = TEAMATE; else if (Content("NW","EMPTY")) Surround[NW] = EMPTY; else Surround[NW] = OUT; if (Content("N","BALL")) Surround[N] = BALL; else if (Content("N","OPPONENT")) Surround[N] = OPPONENT; else if (Content("N","TEAMATE")) Surround[N] = TEAMATE; else if (Content("N","EMPTY")) Surround[N] = EMPTY; else Surround[N] = OUT; if (Content("NE","BALL")) Surround[NE] = BALL; else if (Content("NE","OPPONENT")) Surround[NE] = OPPONENT; else if (Content("NE","TEAMATE")) Surround[NE] = TEAMATE; else if (Content("NE","EMPTY")) Surround[NE] = EMPTY; else Surround[NE] = OUT; if (Content("W","BALL")) Surround[W] = BALL; else if (Content("W","OPPONENT")) Surround[W] = OPPONENT; else if (Content("W","TEAMATE")) Surround[W] = TEAMATE; else if (Content("W","EMPTY")) Surround[W] = EMPTY; else Surround[W] = OUT; if (Content("E","BALL")) Surround[E] = BALL; else if (Content("E","OPPONENT")) Surround[E] = OPPONENT; else if (Content("E","TEAMATE")) Surround[E] = TEAMATE; else if (Content("E","EMPTY")) Surround[E] = EMPTY; else Surround[E] = OUT; if (Content("SW","BALL")) Surround[SW] = BALL; else if (Content("SW","OPPONENT")) Surround[SW] = OPPONENT; else if (Content("SW","TEAMATE")) Surround[SW] = TEAMATE; else if (Content("SW","EMPTY")) Surround[SW] = EMPTY; else Surround[SW] = OUT; if (Content("S","BALL")) Surround[S] = BALL; else if (Content("S","OPPONENT")) Surround[S] = OPPONENT; else if (Content("S","TEAMATE")) Surround[S] = TEAMATE; else if (Content("S","EMPTY")) Surround[S] = EMPTY; else Surround[S] = OUT; if (Content("SE","BALL")) Surround[SE] = BALL; else if (Content("SE","OPPONENT")) Surround[SE] = OPPONENT; else if (Content("SE","TEAMATE")) Surround[SE] = TEAMATE; else if (Content("SE","EMPTY")) Surround[SE] = EMPTY; else Surround[SE] = OUT; // Turn the ball direction into a more useful format if (!strcmp(BallDir(), "N")) BallDirection = N; else if (!strcmp(BallDir(), "NW")) BallDirection = NW; else if (!strcmp(BallDir(), "NE")) BallDirection = NE; else if (!strcmp(BallDir(), "S")) BallDirection = S; else if (!strcmp(BallDir(), "SW")) BallDirection = SW; else if (!strcmp(BallDir(), "SE")) BallDirection = SE; else if (!strcmp(BallDir(), "W")) BallDirection = W; else if (!strcmp(BallDir(), "E")) BallDirection = E; }