Is it the future: ChatGPT

We are in the era of artificial intelligence. I remember when Google launched in the beginning of 2000’s. It was very useful tool for searching with a single simple box and fast true results. Now we are in the late of 2022 and there is ChatGPT. ChatGPT is a very special chat bot with powered by AI(Artificial Intelligence). It can answer any question asked by you. Also it can write short stories and poems. Not finished yet. It can create codes about your questions. For example I asked to ChatGPT “Can you code me a tic tac toe game on python?” and result was amazing. You can see the code below. It is fully coded and described by ChatGPT and works well.

board = [[" ", " ", " "],
         [" ", " ", " "],
         [" ", " ", " "]]

def print_board():
    for row in board:
        print("|".join(row))

def make_move(player, row, col):
    if board[row][col] == " ":
        board[row][col] = player
        return True
    else:
        return False

def game_over():
    # Check rows
    for row in board:
        if row == ["X", "X", "X"]:
            return "X"
        elif row == ["O", "O", "O"]:
            return "O"

    # Check columns
    for col in range(3):
        if board[0][col] == board[1][col] == board[2][col] and board[0][col] != " ":
            return board[0][col]

    # Check diagonals
    if board[0][0] == board[1][1] == board[2][2] and board[0][0] != " ":
        return board[0][0]
    if board[0][2] == board[1][1] == board[2][0] and board[0][2] != " ":
        return board[0][2]

    # Check for tie
    if all([all(row) for row in board]):
        return "TIE"

    # Game is not over yet
    return None

# Initialize game
player = "X"
game_over_flag = False

while not game_over_flag:
    print_board()
    row = int(input("Enter row (0-2): "))
    col = int(input("Enter column (0-2): "))

    if not make_move(player, row, col):
        print("Invalid move! Try again.")
        continue

    if game_over() is not None:
        game_over_flag = True

    player = "O" if player == "X" else "X"

# Print final result
print_board()
result = game_over()
if result == "TIE":
    print("It's a tie!")
else:
    print(f"{result} wins!")

Leave a Reply

Your email address will not be published. Required fields are marked *