elif table[0][2] == "X" and table[2][2] == "X" and table[1][0] == "X" and table[1][2] == "O" and table[1][1] == "O" and table[0][1] == "-" and table[0][0] == "-" and table[2][1] == "-" and table[2][0] == "-": if random.randrange(0,2) == 0: emptyspots.remove("a1") table[0][0] = "O" else: emptyspots.remove("a3") table[2][0] = "O" print(" ") print(" ", " a", " b", " c", " ") print(" 1[", table[0][0], "|", table[0][1], "|", table[0][2], "]") print(" 2[", table[1][0], "|", table[1][1], "|", table[1][2], "]") print(" 3[", table[2][0], "|", table[2][1], "|", table[2][2], "]") print(" ") return "special1r1"
This code is responsible for the AI's decision making. It will look for the possibility for creating a fork and choose a move that is needed for creating one. The moves that are being analyzed are the ones that are possible for creating two in a rows and the ones that are needed to be able to create them. If it finds an opportunity to do so, it will choose a spot that is needed for creating the fork. ## Acknowledgments * [PurpleBooth](https://github.com/PurpleBooth/a-good-readme-template/blob/master/README.md) - The README template