I Made an Impossible Tic Tac Toe AI

Поділитися
Вставка

КОМЕНТАРІ • 22

  • @AnvithV
    @AnvithV Рік тому

    I'm new to programming and I'm trying to make an Impossible Tic Tac Toe game in C. It's really interesting to me to look at other people's work and realize how much I have to explore.

    • @wsalevan
      @wsalevan  11 місяців тому +1

      Yeah it's crazy how much research goes into some of these projects. That video that I linked in the description offers an excellent description and the pseudocode he provides is very helpful, so I found that it was enough to complete the project. Though it would be much harder in C

  • @Thxtnt
    @Thxtnt 2 місяці тому

    C# game engine moment

  • @lukesmith121
    @lukesmith121 3 роки тому +2

    I like this style video

    • @wsalevan
      @wsalevan  3 роки тому

      Thanks! I'll do more of them

  • @thumbnasiuminc4373
    @thumbnasiuminc4373 3 роки тому +2

    Any chance we could have the final code file? I tried recreating it step by step by scrubbing thru the vid, but am missing a few lines. Mainly I just need to see the updated methods VeryEasyAIMove(), NormalAIMove, and HardAIMove()

    • @wsalevan
      @wsalevan  3 роки тому +3

      Sure!
      I set up a github page for the project: github.com/EvanatorM/TicTacToeMinimaxAI
      I also have a pastebin page for just the script: pastebin.com/Nsp8XG6B

    • @thumbnasiuminc4373
      @thumbnasiuminc4373 3 роки тому +1

      @@wsalevan Oh man... Thank you so much!

    • @wsalevan
      @wsalevan  3 роки тому +1

      You're welcome!

    • @thumbnasiuminc4373
      @thumbnasiuminc4373 3 роки тому +1

      ​@@wsalevan You are way better at this than you give yourself credit for :) Question: I noticed you got rid of the single player option while refactoring. You used to have it declared under Game Info, and then you did a check for it in both SpaceClicked() and AiMove(). Are those the only two places I should be concerned with if I were to try and reimplement it on my end?

    • @wsalevan
      @wsalevan  3 роки тому +1

      Thanks! I removed the hardcoded single player option, but it is still possible to play single player without changing the script. The change I did to it was adding the ability to choose whether the players are AIs or not. On the tic tac toe manager object, there are 2 variables: player 1 ai and player 2 ai. If you uncheck one of them, the player will play for that player instead of the ai.

  • @erikkoci9483
    @erikkoci9483 3 роки тому +1

    hi! can you please help me with only the minimax function...? idk why the AI doesn't do the best choice...

    • @wsalevan
      @wsalevan  3 роки тому +1

      Yeah. Can I see the code you're using? Also, what depth are you using?

    • @erikkoci9483
      @erikkoci9483 3 роки тому

      @@wsalevan this is my code pastebin.com/F96qephT Thank you so much!

    • @wsalevan
      @wsalevan  3 роки тому +1

      @Erik Koci I looked at your code and I have a few suggestions. I'm not the best programmer so I might have missed a bigger issue but I will try my best.
      First of all, if this is for tic-tac-toe, make the evaluate function return a different number if it's a tie than if the game isn't finished. If the game is a tie, it should return 0 because it isn't a positive or negative thing. If the game isn't over, return a different number that signifies that the game isn't over yet. For instance, I have mine return -1 if the game isn't over yet, and the minimax function recognizes that as the game not being over.
      Also, it looks like when you call the minimax function within the minimax function, you're passing in the same board that it started with, making it evaluate the same one every time. Make sure it gets the possible moves from that board and calls the minimax function for each one.
      It also doesn't look like you're factoring depth into the function. At the beginning where it checks if the game is over, there should also be a check to see if the depth is 0. Also, depth should be subtracting every time instead of adding.
      I don't know what board.FC is or what the markCell function does. Maybe some of these points were being done with some of these functions. Is this the case? Tell me if this helps!
      Also, would you want me to make a tutorial on minimax and explain how it works and how to make it?

    • @erikkoci9483
      @erikkoci9483 3 роки тому +1

      @@wsalevan thank you very much for the advise! I need to change the evaluate function as you said!
      board.FC = get the unmarked cell from the board ( is an element of the object board)
      markCell = mark a cell (Example ----> markCell(2,1) ----> mark the cell x->2 | y->1
      I've tried my code and i'm not passing the same board!
      I have only a last question ;)
      the depth from which value start?
      I understand the minimax concept but if you have time I really accept a video where you explain how to make it!
      Thank you so much again! you are really very helpful!

    • @wsalevan
      @wsalevan  3 роки тому +1

      You're welcome! The depth value should be higher the harder your ai is. I will make a video about it

  • @kawins1577
    @kawins1577 3 роки тому

    I liked this video