Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Fixing Tic-Tac-Toe Minimax: Why Your AI Makes Suboptimal Moves

  • vlogommentary
  • 2025-12-19
  • 0
Fixing Tic-Tac-Toe Minimax: Why Your AI Makes Suboptimal Moves
Trying to implement tic-tac-toe using minimax algortighm but getting not optimal movespythontic-tac-toeminimax
  • ok logo

Скачать Fixing Tic-Tac-Toe Minimax: Why Your AI Makes Suboptimal Moves бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Fixing Tic-Tac-Toe Minimax: Why Your AI Makes Suboptimal Moves или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Fixing Tic-Tac-Toe Minimax: Why Your AI Makes Suboptimal Moves бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Fixing Tic-Tac-Toe Minimax: Why Your AI Makes Suboptimal Moves

Learn how to properly implement the minimax algorithm for tic-tac-toe and avoid common pitfalls that lead to poor AI moves and non-blocking behavior.
---
This video is based on the question https://stackoverflow.com/q/79478383/ asked by the user 'Jakob Augsburg' ( https://stackoverflow.com/u/24397352/ ) and on the answer https://stackoverflow.com/a/79478707/ provided by the user 'trincot' ( https://stackoverflow.com/u/5459839/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.

Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Trying to implement tic-tac-toe using minimax algortighm, but getting not optimal moves

Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.

If anything seems off to you, please feel free to drop me a comment under this video.
---
Understanding the Problem

You're implementing tic-tac-toe with the minimax algorithm, but your AI chooses bad moves, often ignoring obvious threats or playing non-optimal positions. For example, it repeatedly starts in the same non-center corner and doesn't block opponents from winning.

This behavior typically stems from issues in the evaluation and player perspective within the minimax implementation.

Core Issues and Solutions

1. Misaligned Reward Calculation

The reward function must reflect the perspective of the maximizing player (the one currently choosing moves). Your existing function compares the winner to the turn property, but turn switches to the opponent after a move is made.

Problem:

You reward the player whose turn it is in the current state, but that state belongs to the opponent after a move.

Fix:

Return a score of 1 if the winner matches the maximizing player, not the turn flag.

Example fix in reward:

[[See Video to Reveal this Text or Code Snippet]]

Or more generally, pass the maximizing player to reward and check against it.

2. Neutral Evaluation Score for Non-Terminal States

Your evaluate function returns 0 (loss) for non-terminal states. This biases minimax incorrectly.

Solution:

Return a neutral score (e.g., 0.5) for non-terminal states to avoid skewing the AI away from exploring moves.

[[See Video to Reveal this Text or Code Snippet]]

3. Insufficient Search Depth

A depth of 5 plies (half-moves) is sometimes too shallow for tic-tac-toe and might lead to missing winning or blocking moves.

Recommendation:

Increase the minimax search depth to at least 6 to improve move quality.

[[See Video to Reveal this Text or Code Snippet]]

Additional Best Practices

Use self for method parameters to follow Python conventions.

Cache winning combinations to avoid redundant computation.

Simplify find_winner by directly checking for three-in-a-row without looping over players.

Use the turn boolean to determine maximizing/minimizing player instead of a separate parameter.

Replace inefficient board checks (e.g., not any(spot is None for spot in board_state)) with None not in board_state.

For stronger AI, factor in quicker wins/losses by weighting the depth, making faster wins score higher and delays in losing preferred.

Consider bitboard representation for improved performance and elegant win detection if expanding this project.

Summary

The main bug is the misalignment between the player perspective in reward and the turn variable. Adjusting this to match the maximizing player and fixing evaluation scores, alongside increasing search depth, will drastically improve AI moves.

Keep your functions clean and consistent, and you'll have a competitive tic-tac-toe AI choosing optimal moves and blocking threats perfectly.

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]