Test AStarSearch using a grid with more obstacles.

------------------------------------------------------------------------
See also AStarSearch, TransformGridCoordinates, Plot2D, TextS
------------------------------------------------------------------------

Contents

%-------------------------------------------------------------------------
%   Copyright (c) 2003 Princeton Satellite Systems, Inc. All rights reserved.
%-------------------------------------------------------------------------


n                          = 6;
d                          = struct;
d.pathCostEstimateFunction = 'GridPathCost';
d.traverseCostFunction     = 'GridTraverseCost';
d.successorNodesFunction   = 'GridSuccessorNodes';
grid                       = zeros(n,n);
d.myData.n                 = n;

blockedNode                = [4 4 3 3 4 5;4 5 4 2 2 2];
for k = 1:size(blockedNode,2)
  grid(blockedNode(1,k),blockedNode(2,k)) = 1;
end

Put in a one dimensional array

%-------------------------------
for k = 1:n
  d.myData.grid(1,((k-1)*n+1):(k*n)) = grid(k,:);
end
d.n  = length(d.myData.grid);

startNode = TransformGridCoordinates( 4, 1, n );
endNode   = TransformGridCoordinates( 4, 6, n );

path      = AStarSearch( startNode, endNode, d );

[y, x] = TransformGridCoordinates( path, n );

Plot2D( x, y, 'x', 'y', sprintf('A* Search') );
n = n + 1;
set( gca, 'xlim', [0 n], 'ylim', [0 n], 'xtick', 0:n, 'ytick', 0:n )
hold on

[row, col] = TransformGridCoordinates( startNode, n-1 );
TextS(col,row-.15,'  start')
plot(col,row,'*g')
[row, col] = TransformGridCoordinates( endNode, n-1 );
TextS(col,row-.15,'  end')
plot(col,row,'*r')

for k = 1:size(blockedNode,2)
  plot(blockedNode(2,k),blockedNode(1,k),'*k');
end

% PSS internal file version information
%--------------------------------------

% $Id: df6f68c78e719d1982320d7f46ae063266d63907 $