So I have some code to generate possible board states for a connect four board but resized to a 4x4 board.
def generate_board(board, marker, altMarker, collumnCount): global boards boardClone = board.copy() if check(board, marker): return if check(board, altMarker): return if checkTie(board): return for i in range(0, 4): collumnCountClone = collumnCount.copy() if collumnCountClone [i] != 0: boardClone[collumnCountClone [i] - 1][i] = marker collumnCountClone [i] -= 1 if boardClone not in boards: boards.append(boardClone) generate_board(boardClone, altMarker, marker, collumnCountClone) generate_board([[" ", " ", " ", " "], [" ", " ", " ", " "], [" ", " ", " ", " "], [" ", " ", " ", " "]], "B", "R", collumnCount) But the problem with this is it returns a recursion error. Now I know your probably thinking to just use the sys module and set the recursion amount, but for some reason when I do this the code says it finished but really it doesn't even print the boards, in fact no print line even comes up, it just finishes the code without doing anything. Does anyone know how to help. I have tried many different things but they don't work at all?
https://stackoverflow.com/questions/66523819/how-to-fix-python-recursion-error-when-sys-module-doesnt-work March 08, 2021 at 11:04AM
没有评论:
发表评论