matlab 自动扫雷,matlab自动扫雷(2)——排雷插旗 -凯发k8官方网
如果周围8个方块和当中数字判断周围有空白方块
% 点击白块
function click_blank()
global map
global blocks_x
global blocks_y
global left
global top
global block_width
global block_height
showmap();
iscluck = 0;
for y=1:blocks_y
for x=1:blocks_x
if (1 <= map(x,y)) && (map(x,y) <= 8)
boom_number = map(x,y);
block_white = 0;
block_qi = 0;
for yy=(y - 1):(y 1)
for xx=(x - 1):(x 1)
if (1 <= yy) && (1 <= xx) && (yy <= blocks_y) && (xx <= blocks_x)
if ~((yy == y) && (xx == x))
if map(xx,yy) == 0
block_white = block_white 1;
elseif map(xx,yy) == -4
block_qi = block_qi 1;
end
end
end
end
end
if boom_number == block_qi && block_white > 0
for yy=(y - 1):(y 1)
for xx=(x - 1):(x 1)
if (1 <= yy) && (1 <= xx) && (yy <= blocks_y) && (xx <= blocks_x)
if ~((yy == y) && (xx == x))
if map(xx,yy) == 0
disp("点开")
win.setmouse(left (xx-1) * block_width 5,...
top (yy-1) * block_height 5);
win.leftclick;
iscluck = 1;
end
end
end
end
end
end
end
end
end
if iscluck == 0 && ~all(all(map~=0))
luck();
end
win.setmouse(50,50);
end
总结
以上是凯发k8官方网为你收集整理的matlab 自动扫雷,matlab自动扫雷(2)——排雷插旗的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: matlab高中必修三数学模拟,基于ma
- 下一篇: