Click Here To Download This Answer Instantly


Checking if a player has a win in a diagonal. We have a final sub-function to check if a player has a win in any diagonal direction. Create a function named winInDiag (notice the use of a lowercase w. but uppercase I and D). The function will take 2 parameters:1.a two-dimensional list that holds a representation of the board game-state2.the piece type of one of the players. This function should return True if there are 3 pieces in a row in a forward slash diagonal and a backward slash diagonal. Remember that we have the possibility of diagonals of length 3 and of length 4. You will have to create an implementation that finds 3 in a row in both of these situations. You can’t just find the total number of pieces of the same type in the diagonal. In a diagonal of length 4 there may be 3 pieces with an EMPTY or opponent piece in between them which prevent them from being 3 in a row. This function is more complicated than the previous row, and column versions. You will notice that you are changing both your row and column at the same time. For one direction of diagonal the row/columns will increase/decrease in the same direction. For the other direction when row goes up the column will go down and vice versa. There are a few of ways of doing this function including checking specific indices with a number of if-statements, or through a loop implementation. Either is a valid solution. Be aware, that these functions are asking about a specific piece type. Returning True for 3 in a row for another piece type or not in a diagonal is a wrong implementation and my tests will fail.