from
Edge Tiling
by Krishna Lalith Minimize overall cost for a given box filled with numbered tiles.
[tile_soln,BackTrackCost]=BackTrackAlgo(tiles)
function [tile_soln,BackTrackCost]=BackTrackAlgo(tiles)
BackTrackCost=100;
for ii=1:2,
for jj=1:2,
C=2*(ii-1)+jj;
for kk=1:4,
for ll=1:4,
tmp(1,ll)=tiles(C,1+mod(ll,4));
end
tiles(C,:)=tmp(1,:);
Total_Cost=costly(tiles);
if BackTrackCost>Total_Cost,
BackTrackCost=Total_Cost;
tile_soln=tiles;
end
end
end
end
% BackTrackCost
% tile_soln