isequivalent.m
来自「一个matlab的将军模型」· M 代码 · 共 51 行
M
51 行
function status=isequivalent(cell1,cell2)
global CELLS
status_boundary=0;
status_hpflags=0;
status_pthflags=0;
status=0;
if length(CELLS{cell1}.boundary) == length(CELLS{cell2}.boundary)
if all(CELLS{cell1}.boundary ==CELLS{cell2}.boundary)
status_boundary=1;
end
end
if length(CELLS{cell1}.hpflags) == length(CELLS{cell2}.hpflags)
if all(CELLS{cell1}.hpflags ==CELLS{cell2}.hpflags)
status_hpflags=1;
end
end
if length(CELLS{cell1}.pthflags) == length(CELLS{cell2}.pthflags)
if all(CELLS{cell1}.pthflags ==CELLS{cell2}.pthflags)
status_pthflags=1;
end
end
if status_pthflags & status_boundary & status_hpflags
status=1;
end
if ~status;
[C,d] = cell_ineq(CELLS{cell1}.boundary,CELLS{cell1}.hpflags);
region1 = linearcon([],[],C,d);
[C,d] = cell_ineq(CELLS{cell2}.boundary,CELLS{cell2}.hpflags);
region2 = linearcon([],[],C,d);
intersection_region=region1®ion2;
if ~isempty(intersection_region)
if isempty(minus(region1,region2))
if isempty(minus(region2,region1))
status=1;
end
end
end
end
return
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?