+ 4

[Challenging question] checking 2d array[tic tac toe]

I already did my Tic Tac Toe game in python using Minimax algorithm( only 3x3 board) . So I decided i will try to make tic tac toe AI for bigger boards. Problem I had was my checkWin function. It is not that easy to check if anybody win,if player can choose size of the board(for example 5x10, 7x2). Today finally i completed this checkWin function. I did not use any library like numpy(if i did it would be much, much easier). So i am asking: How would you make this checkWin function. I am still learning python and i am interested how other programmers would do it. (It has to check board vertically, horizontally and all diagonals). More information about my solution in my code. https://code.sololearn.com/c785sAlA6AUS/?ref=app

7th Sep 2020, 10:05 PM
Atom
Atom - avatar
5 ответов
+ 3
Steven M I dont have any issue with my solution, I am just asking for other solutions, for example how would you make this checkWin function. Mirielle I will have a look at your post tommorow. I am tired now. Need to go sleep.
7th Sep 2020, 10:50 PM
Atom
Atom - avatar
+ 1
I dont understand, I just tested it horizontally, vertically and diagonally, everything seemed to pass. What issues are you experiencing?
7th Sep 2020, 10:43 PM
Steven M
Steven M - avatar
+ 1
Mirielle I am sorry, but I don't understand you. Could you please illustrate this in Sololearn playgroud, like I did with my solution(it should have 2d array, which represents playing board and checkWin function, which returns True if player won, False if player did NOT win) Thanks. https://code.sololearn.com/c785sAlA6AUS/?ref=app
8th Sep 2020, 5:24 AM
Atom
Atom - avatar