#include "gridhunt.h" // Number of Games Played #define ROUNDS 500 #define GRAPH // some Global variables Monster Mob; int games=0, moves=0; /* An Array for all Teams */ Player *team_ptrs[MAX_TEAM]; /* An Array of all 'action-functions' */ void (*team_funcs[MAX_TEAM])(); /* This function assigns the pointers to the team_ptrs & team_funcs */ void assign_pointers() { team_ptrs[0]=&team1; team_ptrs[1]=&team2; team_ptrs[2]=&team3; team_ptrs[3]=&team4; team_ptrs[4]=&team5; team_ptrs[5]=&team6; team_funcs[0]=hunt1; team_funcs[1]=hunt2; team_funcs[2]=hunt3; team_funcs[3]=hunt4; team_funcs[4]=hunt5; team_funcs[5]=hunt6; } /* Update returns the TRUE if a Team has found the monster, * Otherwise FALSE * Compares the coordinates of the Monster with the Coors of the * players. */ int update() { Coor monster; Coor player; int i,ret=FALSE; monster=Mobptr->my_pos(); for(i=0;imy_pos(); if(player==monster) { ret=TRUE; team_ptrs[i]->wins++; #ifdef TEXTOUT cout << "Team "<get_name()<< " has found the monster.\n"; #endif } team_ptrs[i]->tick(); } return ret; } int main_loop() { int up,i; up=update(); games++; moves=0; #ifdef TEXTOUT cout << "Game #"<move(); for(i=0;iset_name("Sea_Hag"); Mobptr->teleport(); } void player_init() { int i; for(i=0;ireset(); } } int main() { int j,avg=0; srandom(time(NULL)); assign_pointers(); for(j=0;jprint_stats(TRUE); } cout << "\nDone in average " << avg/ROUNDS << " Moves.\n"; }