function snakes_plot ( step, v )

%*****************************************************************************80
%
%% snakes_plot() plots the state of a game of Snakes and Ladders.
%
%  Discussion:
%
%    Only squares 1 through 100 will be displayed.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 January 2007
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer STEP, the step of the game.
%
%    real V(101,1), the occupancy level of each square.
%
  if ( nargin < 1 )
    rng ( 'shuffle' );
    v = rand ( 101, 1 );
  end

%  Make the plot.
%
  x_min =  0.5;
  x_max = 10.5;
  y_min =  0.5;
  y_max = 10.5;

  clf ( );
%
%  Make a black background.
%
  patch ( ...
    [ x_min - 1.125, x_min-0.125, x_min-0.125, x_min - 1.125 ], ...
    [ y_min - 0.125, y_min - 0.125, y_min + 1.125, y_min + 1.125 ], ...
    'k', 'EdgeColor', 'none' );

  patch ( ...
    [ x_min - 0.125, x_max + 0.125, x_max + 0.125, x_min - 0.125 ], ...
    [ y_min - 0.125, y_min - 0.125, y_max + 0.125, y_max + 0.125 ], ...
    'k', 'EdgeColor', 'none' );
%
%  Scale the data.
%
  v_max = max ( v(1:101,1) );
  v_min = min ( v(1:101,1) );
  if ( v_min < v_max )
    v = ( v - v_min ) / ( v_max - v_min );
  else
    v = zeros ( 101, 1 );
  end

  for k = 0 : 100
%
%  Determine the (I,J) coordinates of the center of the square.
%
    if ( k == 0 )
      j = 1;
      i = 0;
    else
      j = 1 + floor ( ( k - 1 ) / 10 );
      i = k - 10 * ( j - 1 );
      if ( mod ( j, 2 ) == 0 ) 
        i = 11 - i;
      end
    end
%
%  Determine corners of a box around (I,J).
%
    a = i - 0.44;
    b = i + 0.44;
    c = j - 0.44;
    d = j + 0.44;
%
%  Choose a shade between red and white, whose intensity corresponds
%  to the relative size of V.
%
    rgb(1,1:3) = (  (       v(k+1) ) * [ 1.0, 0.0, 0.0 ]  ...
                  + ( 1.0 - v(k+1) ) * [ 1.0, 1.0, 1.0 ] );
%
%  Draw the square.
%
    patch ( [ a, b, b, a ], [ c, c, d, d ], rgb, 'EdgeColor', 'none' );
    
  end

  axis ( 'equal' );
  axis ( 'square' );
  axis ( 'tight' );

  title ( sprintf ( 'Step %d', step ) );

  if ( false )
    plot_filename = 'snakes.png';
    print ( '-dpng', plot_filename );
    fprintf ( 1, '  Graphics saved as "%s"\n', plot_filename );
  end

  return
end
