function [ w, p ] = t_grid_word ( grid_index )

%*****************************************************************************80
%
%% t_grid_word() returns the boundary word for a T-puzzle grid.
%
%  Discussion:
%
%    The boundary word describes how to trace the boundary by starting
%    at a base point (i,j), and taking a sequence of steps of 
%    in one of 8 directions, as suggested by this diagram:
%
%      D--C--B
%   ^  |\ | /|
%   |  | \|/ |
%   J  E--P--A
%      | /|\ |
%      |/ | \|
%      F--G--H
%
%         I-->
%
%    If the current position P has coordinates (I,J), then
%    the step of given index moves to
%
%      A  (I+1,J  )
%      B  (I+1,J+1)
%      C  (I,  J+1)
%      D  (I-1,J+1)
%      E  (I-1,J  )
%      F  (I-1,J-1)
%      G  (I,  J-1)
%      H  (I+1,J-1)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 December 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer GRID_INDEX: a grid index.
%    1: the T
%    2: the arrow
%    3: the rhombus
%    4: the fat arrow
%
%  Output:
%
%    character W(WN): the boundary word.
%
%    integer P(1,2): the coordinates of the base point.
%
  p = [ 0, 0 ];
%
%  T
%
  if ( grid_index == 1 )
    w = 'AAACCCCCCCCCAAACCCEEEEEEEEEGGGAAAGGGGGGGGG';
%
%  Arrow
%
  elseif ( grid_index == 2 )
    w = 'AAACCCCCCAAAADDDDDDFFFFFFAAAAAGGGGGG';
%
%  Rhombus
%
  elseif ( grid_index == 3 )
    w = 'AAAAAAAAABBBBBBEEEEEEEEEFFFFFF';
%
%  Fat Arrow
%
  elseif ( grid_index == 4 )
    w = 'AAAAAACCCAAADDDDDDFFFFFFAAAGGG';
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, 't_grid_word(): Fatal error!\n' );
    fprintf ( 1, '  Illegal grid index %d\n', grid_index );
    error ( 't_grid_word(): Fatal error!\n' );
  end

  return
end

