Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A function never called in tictactoe2.py #801

Open
Vaxick opened this issue Sep 5, 2022 · 1 comment
Open

A function never called in tictactoe2.py #801

Vaxick opened this issue Sep 5, 2022 · 1 comment

Comments

@Vaxick
Copy link
Contributor

Vaxick commented Sep 5, 2022

Just watched the code of this specific file, and noticed that there is a function that is never called

def think(board, g, h, moves):

    if board[Space.MID_CENTER] is OccupiedBy.EMPTY:
        return Space.MID_CENTER

    if board[Space.MID_CENTER] is OccupiedBy.PLAYER:
        if (
            board[Space.TOP_CENTER] is OccupiedBy.PLAYER
            and board[Space.TOP_LEFT] is OccupiedBy.EMPTY
            or board[Space.MID_LEFT] is OccupiedBy.PLAYER
            and board[Space.TOP_LEFT] is OccupiedBy.EMPTY
        ):
            return Space.BOT_LEFT
        elif (
            board[Space.MID_RIGHT] is OccupiedBy.PLAYER
            and board[Space.BOT_RIGHT] is OccupiedBy.EMPTY
            or board[Space.BOT_CENTER] is OccupiedBy.PLAYER
            and board[Space.BOT_RIGHT] is OccupiedBy.EMPTY
        ):
            return Space.BOT_RIGHT

    if g == OccupiedBy.PLAYER:
        j = 3 * int((moves - 1) / 3)
        if move == j + 1:  # noqa: This definitely is a bug!
            k = 1
        if move == j + 2:  # noqa: This definitely is a bug!
            k = 2
        if move == j + 3:  # noqa: This definitely is a bug!
            k = 3
        return subthink(g, h, j, k)  # noqa: This definitely is a bug!

Isn't it better to just remove it?

@coding-horror
Copy link
Owner

If it's never called, I say we can remove it? Should this be in the porting notes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants