home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 138.lha / Cycle / Flying.c < prev    next >
C/C++ Source or Header  |  1986-11-20  |  796b  |  39 lines

  1. /*
  2.   "Keep 'em Flying" uses a similar stategy to "Round the
  3.   Clock", but looks around starting from her current direction. This
  4.   results in "Keep 'em Flying" prefering her current direction to a new one.
  5. */
  6. #include "cycles.h"
  7.  
  8. char player_name[] = "Keep 'em Flying";
  9.  
  10. long xdir[] = {0,1,0,-1};
  11. long ydir[] = {-1,0,1,0};
  12. long mod4[] = {0,1,2,3,0,1,2,3};
  13.  
  14. strategy_init() {}
  15. strategy_finish() {}
  16.  
  17. strategy()
  18. {
  19.   long x,y,dir;
  20.   long score,best;
  21.   long i,j,k;
  22.  
  23.   GetInfo(&x,&y,&dir);
  24.  
  25.   best = 1000; /* bigger than biggest possible score */
  26.   for (i=0,k=dir; i<4; i++,k++) {
  27.     k = mod4[k];
  28.     if (Look(k)) continue;
  29.     score = 0;
  30.     for (j=2; j<4; j++)
  31.       score += Inquire(x + j*xdir[k],y+ j*ydir[k]);
  32.     if (score < best) {
  33.       best = score;
  34.       dir = k;
  35.     }
  36.   }
  37.   return(dir);
  38. }
  39.