An updated version of the classic "Basic Computer Games" book, with well-written examples in a variety of common MEMORY SAFE, SCRIPTING programming languages. See https://coding-horror.github.io/basic-computer-games/
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!
Just watched the code of this specific file, and noticed that there is a function that is never called
Isn't it better to just remove it?