/*
  This example demonstrates how a Turn Right player can be made
  Turn Right is the CodeCup game 2006 (www.codecup.nl)
  The use of this file and/or ideas is not compulsory
  Left to do: fifteen TODOs
  This example is written by Marcel Vlastuin
  Use Caia to play Turn Right games (and more...) at your own house
  Success and a lot of joy in the contest!
*/

#include <stdio.h>

#include <string.h>

#include <stdlib.h>


int maximumcorners;
// You will have to deal with the maximum number of corners in a snake

// You can (not compulsory) store the board like this:
int board[36]; // This solution is used in this example

int translate_move_to_own_notation(char inputline[])
{
  int move;
  // TRANSLATE inputline[] INTO move
  return move;
}

int *translate_snake_to_own_notation(char inputline[], int *snakelength)
{
  static int snake[100];
  // TRANSLATE inputline[] INTO snake[] AND *snakelength
  return snake;
}

char *translate_move_to_text(int move)
{
  static char text[100];
  // TRANSLATE move INTO text[]
  return text;  
}

char *translate_snake_to_text(int snake[], int snakelength)
{
  static char text[100];
  // TRANSLATE snake[] AND snakelength INTO text[]
  return text;  
}

void process_whitemove(int move)
{
  // PROCESS THE move IN board[36]
}

void process_blackmove(int move)
{
  // PROCESS THE move IN board[36]
}

void turn_clockwise(int snake[], int snakelength)
{
  // TURN snake[] WITH snakelength CLOCKWISE IN board[36]
}

int calculate_best_whitemove(void)
{
  int move;
  // CALCULATE move USING board[36]
  return move;
}

int calculate_best_blackmove(void)
{
  int move;
  // CALCULATE move USING board[36]
  return move;
}

int find_last_blackmove(void)
{
  int move;
  // FIND move IN board[36]
  return move;
}

int *calculate_best_whitesnake(int *snakelength)
{
  static int snake[100];
  // CALCULATE snake[] AND *snakelength USING board[36] AND maximumcorners
  return snake;
}

int *calculate_best_blacksnake(int *snakelength)
{
  static int snake[100];
  // CALCULATE snake[] AND *snakelength USING board[36] AND maximumcorners
  return snake;
}

int check_end_game(void)
{
  int yes_or_no;
  // CALCULATE yes_or_no
  return yes_or_no;
}

int main(void)
{
  int count;
  int move;

  // You can (not compulsory) use this line:
  int *snake, snakelength;
  // snake = pointer to a static array of integers
  // snakelength = the number of integers stored in snake[]
  // This solution is used in this example

  char inputline[100];
  maximumcorners=4;
  scanf("%s", inputline);
  if (strcmp("Start", inputline)==0)
  { // White starts
    count=0;
    while (1)
    {
      move=calculate_best_whitemove();
      process_whitemove(move);
      printf("%s\n", translate_move_to_text(move));
      fflush(stdout);
      ++count;
      if (count==35) break;
      scanf("%s", inputline);
      if (strcmp("x", inputline)==0) exit(0);
      move=translate_move_to_own_notation(inputline);
      process_blackmove(move);
      ++count;
    }
    move=find_last_blackmove();
    process_blackmove(move);
    for (count=0; count<13; ++count)
    {
      maximumcorners=4+2*count;
      scanf("%s", inputline);
      if (strcmp("x", inputline)==0) exit(0);
      snake=translate_snake_to_own_notation(inputline, &snakelength);
      turn_clockwise(snake, snakelength);
      snake=calculate_best_whitesnake(&snakelength);
      turn_clockwise(snake, snakelength);
      printf("%s\n", translate_snake_to_text(snake, snakelength));
      fflush(stdout);
      if (check_end_game()) exit(0);
    }
  }
  else
  { // Black starts
    count=0;
    while (1)
    {
      if (strcmp("x", inputline)==0) exit(0);
      move=translate_move_to_own_notation(inputline);
      process_whitemove(move);
      ++count;
      if (count==35) break;
      move=calculate_best_blackmove();
      process_blackmove(move);
      printf("%s\n", translate_move_to_text(move));
      fflush(stdout);
      ++count;
      scanf("%s", inputline);
    }
    move=find_last_blackmove();
    process_blackmove(move);
    for (count=0; count<13; ++count)
    {
      maximumcorners=4+2*count;
      snake=calculate_best_blacksnake(&snakelength);
      turn_clockwise(snake, snakelength);
      printf("%s\n", translate_snake_to_text(snake, snakelength));      
      fflush(stdout);
      if (count==12 || check_end_game()) exit(0);
      scanf("%s", inputline);
      if (strcmp("x", inputline)==0) exit(0);
      snake=translate_snake_to_own_notation(inputline, &snakelength);
      turn_clockwise(snake, snakelength);
    }  
  }
  return 0;
}



syntax highlighted by Code2HTML, v. 0.9.1