program CodeCup;

{
  Example of a Caissa player program for the CodeCup.

  This only demonstrates how to do the input and output. You will
  have to write the algorithms for the game all by yourself.
}


var
  { This variable is set to True if we are playing white. }
  IAmPlayingWhite: Boolean;


{ This procedure resets the game board to the initial position. }
procedure InitGameBoard;
begin
  { TODO }
end;


{ This procedure selects the best move for us to make now. }
procedure SelectMyBestMove(var fromcol, fromrow, tocol, torow: LongInt);
begin
  { TODO }
end;


{ This procedure updates the game board with a move from the opponent. }
procedure DoOpponentMove(fromcol, fromrow, tocol, torow: LongInt);
begin
  { TODO }
end;


{ Main program }
var
  line: String;
  fromcol, fromrow, tocol, torow: LongInt;
  

begin
  { Set the game board to its initial position }
  InitGameBoard;

  { Read the first line of input }
  ReadLn(line);

  { The first line contains 'start' if we are playing white }
  if line = 'start' then begin

    { We are playing white }
    IAmPlayingWhite := True;

    { Select our first move }
    SelectMyBestMove(fromcol, fromrow, tocol, torow);

    { Write our first move }
    WriteLn(Chr(Ord('a') + fromcol), fromrow, '-',
            Chr(Ord('a') + tocol), torow);
    Flush(Output);

    { Read the next line of input }
    ReadLn(line);

  end
  else begin

    { We are playing black }
    IAmPlayingWhite := False;

  end;

  { Repeat this until the end of the game }
  while line <> 'end' do begin

    { Parse the opponent's move }
    fromcol := Ord(line[1]) - Ord('a') + 1;
    fromrow := Ord(line[2]) - Ord('1') + 1;
    tocol := Ord(line[4]) - Ord('a') + 1;
    torow := Ord(line[5]) - Ord('1') + 1;

    { Update the game board }
    DoOpponentMove(fromcol, fromrow, tocol, torow);

    { Select our best move }
    SelectMyBestMove(fromcol, fromrow, tocol, torow);

    { Write the selected move to the output }
    WriteLn(Chr(Ord('a') + fromcol - 1), fromrow, '-',
            Chr(Ord('a') + tocol - 1), torow);
    Flush(Output);

    { Read the next line of input }
    ReadLn(line);

  end;

end.

syntax highlighted by Code2HTML, v. 0.9.1