// Return the operator's category that is the lowest among the applicable // operators for state. public static int LowestOperatorCategory(GoBangBoard board) { // A maximum, not important, just must be larger than any real // category int max = 99; // Search category 0 and 1 in G_5 foreach (GoBangBoard.StoneSet ss in board.G5) { // There is no category below zero, so we can return early. if (GBOperatorFive.Present(ss)) { return(0); } if (GBOperatorFour.Present(ss)) { max = 1; } } if (max < 99) { return(max); } // Search category 1 and 2 in G_6 foreach (GoBangBoard.StoneSet ss in board.G6) { // If there was no 0/1 before, this is certainly the minimum. if (GBOperatorStraightFour.Present(ss)) { return(1); } if (max > 2 && GBOperatorBrokenThree.Present(ss)) { max = 2; } else if (max > 2 && GBOperatorThree3.Present(ss)) { max = 2; } } if (max < 99) { return(max); } foreach (GoBangBoard.StoneSet ss in board.G7) { if (GBOperatorThree2.Present(ss)) { return(2); } } return(99); }