winform窗体,五子棋,怎么判断 连够了五个
winform窗体,五子棋,怎么判断 连够了五个
------解决方案--------------------for (int i = 0; i < 10 - 4; i++)
for (int j = 0; j < 10 - 4; j++) //假设是10x10的棋盘
{
if data[i, j] == state.black && data[i, j] == state.white)
{
if (new state[] { data[i, j], data[i + 1, j], data[i + 2, j], data[i + 3, j], data[i + 4, j] }.GroupBy(x => x).Count() == 1) return true; //横
if (new state[] { data[i, j], data[i1, j + ], data[i, j + 2], data[i, j + 3], data[i, j + 4] }.GroupBy(x => x).Count() == 1) return true; //竖
if (new state[] { data[i, j], data[i + 1, j + 1], data[i + 2, j + 2], data[i + 3, j + 3], data[i + 4, j + 4] }.GroupBy(x => x).Count() == 1) return true; //斜
}
}
return false;