count := 0;
for i := 1 to 4 do
begin
if(pos.X+i<=maxx)and(pos.Y+i<=maxY)//确保棋子在棋盘内
and (Gobang[pos.X+i,pos.Y+i]=InColor then
inc(count)
else
break;
end;
for i := 1 to 4 do
begin
if (0<=pos.X-i)and(0<=pos.Y-i)
and (Gobang[pos.X-i,pos.Y-i]=InColor then
inc(count)
else
break;
end;
inc(count);
if count>5 then
begin
...//到这里就是有禁手了
exit;//并退出本次整个过程
end;