![]() If it contains only one element, then the game has been won. You can just make a set of each row, and check its length. The code doesn't seem to do that and even when I checked with the following "board" it gave me an output of "True" check_list = , Then it would give a bool value of True otherwise False. It does this until it finds n elements in the same row. ![]() If that element matches the "decorator" then it continues and checks the next but if it doesn't, then it breaks from the first loop and goes to the next row. Then loops through the values in each row. What I hope to accomplish is that the function loops through the 2D array's rows. Where "board" is a 2D array of size n^2 and "decorator" is the "X" or "O" value I feel that this is something that needs a bit of hardcoding. This code only checks for horizontal lines, I haven't added the rest. I have written the following function to do so: I am trying to write a code that determines the winner of a tic-tac-toe game.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |