我知道有很多关于连接4检查获胜的问题.问题是大多数其他算法使我的程序有运行时错误,因为它们试图访问我的数组之外的索引.我的算法是这样的:
private int checkWin(int[][] gridTable,int rowNum,int colNum, int maxRow, int maxCol)
{
// For checking whether any win or lose condition is reached. Returns 1 if win or lose is reached. else returns 0
// gridTable[][] is the game matrix(can be any number of rows and columns between 4 and 40)
// colNum is the column number where the last token was placed
// rowNum is the row number where the last token was placed
// maxRow is the number …Run Code Online (Sandbox Code Playgroud)