/*
  "Keep 'em Flying" uses a similar stategy to "Round the
  Clock", but looks around starting from her current direction. This
  results in "Keep 'em Flying" prefering her current direction to a new one.
*/
#include "cycles.h"

char player_name[] = "Keep 'em Flying";

long xdir[] = {0,1,0,-1};
long ydir[] = {-1,0,1,0};
long mod4[] = {0,1,2,3,0,1,2,3};

strategy_init() {}
strategy_finish() {}

strategy()
{
  long x,y,dir;
  long score,best;
  long i,j,k;

  GetInfo(&x,&y,&dir);

  best = 1000; /* bigger than biggest possible score */
  for (i=0,k=dir; i<4; i++,k++) {
    k = mod4[k];
    if (Look(k)) continue;
    score = 0;
    for (j=2; j<4; j++)
      score += Inquire(x + j*xdir[k],y+ j*ydir[k]);
    if (score < best) {
      best = score;
      dir = k;
    }
  }
  return(dir);
}
