SwiftUI Tic Tac Toe | Multiple AI Difficulties | MVVM | Portfolio Project

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 29. 06. 2024
  • Head to squarespace.com/seanallen to save 10% off your first purchase of a website or domain using code SEANALLEN.
    Today we're building a Tic Tac Toe game in SwiftUI. But we are stepping it up a notch and building out the logic for our computer AI opponent to scale in difficulty. We will build the game board UI in SwiftUI, then check for win or draw conditions, then build up our AI logic and we'll finish up by refactoring into MVVM (Model View ViewModel). There's a lot to learn in this video so I hope you complete it 😀.
    This video kicks off my "Portfolio Project" series for iOS developers in SwiftUI. This series is all about create fun little projects to help build up your portfolio. The idea is for you build upon these projects and make them your own. Use them as a baseline.
    This tutorial was created in Xcode 12.5 and Swift 5.4.
    SF Symbols Video:
    ‱ What's New in SFSymbol...
    If you like my teaching or presentation style, I've started creating my own courses:
    seanallen.teachable.com/
    Timestamps
    What Are We Building? - 0:00
    Game Board UI - 1:12
    Create Move Object - 9:36
    Check if Square is Occupied - 17:07
    Start Computer AI - Easy Mode - 20:33
    AI Logic Overview - 23:16
    Computer Moves - 23:37
    Disable Game Board - 28:43
    Win & Draw Conditions - 31:27
    Win, Lose or Draw Alerts - 43:17
    Making our AI Smarter - 52:35
    Refactor & MVVM - 1:03:53
    Recommendations - 1:17:39
    Twitter:
    / seanallen_dev
    Link to my book - How I Became an iOS Developer:
    gumroad.com/l/sean-allen-origin
    Hired.com:
    hired.com/x/1n01g
    Check out my podcast, iOS Dev Discussions:
    itunes.apple.com/us/podcast/i...
    Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):
    Ray Wenderlich Books:
    store.raywenderlich.com/a/208...
    Ray Wenderlich Videos:
    store.raywenderlich.com/a/208...
    Paul Hudson's Hacking With Swift:
    gumroad.com/a/762098803
    Learn Advanced Swift Here:
    gumroad.com/a/656585843
    Links to my iOS Dev Setup & iOS Dev Book Recommendations
    www.amazon.com/shop/seanallen
    #swift #softwaredeveloper #iosdeveloper
  • Věda a technologie

Komentáƙe • 144

  • @seanallen
    @seanallen  Pƙed 3 lety +8

    If you enjoy my teaching/presentation stye, I've started creating my own iOS dev courses at seanallen.teachable.com. You can watch the first ~10% for free to get a feel for them.

    • @ericibrahim8871
      @ericibrahim8871 Pƙed 3 lety

      A tip: you can watch series at flixzone. Been using it for watching lots of of movies recently.

    • @leosamir8840
      @leosamir8840 Pƙed 3 lety

      @Eric Ibrahim definitely, I have been watching on Flixzone for since november myself :D

  • @jeffcournoyer5249
    @jeffcournoyer5249 Pƙed 3 lety +14

    Every time I watch one of your videos, I’m reminded about how much I actually want to do this for a living! Thanks for all the great lessons!

    • @seanallen
      @seanallen  Pƙed 3 lety +3

      Happy to hear that, Jeff. Go get it!

  • @chrispy104k
    @chrispy104k Pƙed 3 lety +5

    "....Use the 'bang' in front....". Never fails to amuse me.
    Great tutorial Sean.
    Tip: (you may already have heard this one but I know it's hard to remember it when you need it) When you have multiple instances of a bunch of variables that you want to change, lets say the prefix on them, you can create multiple cursors. Click at the beginning of the first one then hold the Control and Shift key down and click in front of the others. Now you can edit them simultaneously.

    • @seanallen
      @seanallen  Pƙed 3 lety +2

      I always forget that one. It's funny... I've done plenty of Xcode tips and tricks videos where I show all this stuff off, but it's hard to remember them all.

  • @bestformspielt
    @bestformspielt Pƙed 3 lety +3

    I like your "chapter" analogy when talking about refactoring. That's exactly how you should think about it.

  • @christostsangaris4785
    @christostsangaris4785 Pƙed 3 lety +17

    When you see Sean posting a video you are 100% sure about the quality and the knowledge you gonna get! Awesome!! Thanks for everything Sean!

    • @seanallen
      @seanallen  Pƙed 3 lety +1

      Thanks for the kind words, Christos 😀

  • @iOSAcademy
    @iOSAcademy Pƙed 3 lety +13

    This is a super good end to end video, great job!

    • @seanallen
      @seanallen  Pƙed 3 lety +2

      Thanks man!

    • @colgates.
      @colgates. Pƙed 3 lety +2

      Thanks to both of you👍

    • @naqeebahmed7113
      @naqeebahmed7113 Pƙed 3 lety +1

      both of you guys are doing great job for iOS developer.Thank you :)

  • @piyushagrawal08
    @piyushagrawal08 Pƙed 3 lety +3

    You are great! ... Nice to see you back with fire! Awesome...

  • @kailashanand5086
    @kailashanand5086 Pƙed 2 lety

    great video! very comprehensive and helpful. it was just detailed enough that it didn't get boring at any point! loved it, keep up the great work!

  • @UTubeIsMessingUp
    @UTubeIsMessingUp Pƙed 2 lety +1

    Great video man, its been about 5 years since I worked on ios and just took another 3 hour course on the basics. This gave me a lot to play around with as a first project, thank you!

  • @rdtba21qw
    @rdtba21qw Pƙed 3 lety +2

    Great stuff as always Sean - love the way you do those alerts. Thank you.

  • @wadaienglish1123
    @wadaienglish1123 Pƙed 2 lety

    Came here looking for something else, but I found this so interesting and helpful, I stayed for it all. Great tutorial as always from Sean Allen.

  • @thenotoriousDFL
    @thenotoriousDFL Pƙed 2 lety +1

    For those of you too lazy to type: let winPatterns: Set = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6]]

  • @MikaelaCaron
    @MikaelaCaron Pƙed 3 lety +2

    Cool serious idea Sean! Excited to see these new videos.

  • @laurapotter6321
    @laurapotter6321 Pƙed 2 lety

    I just love watch your video x1.5 speed to enforce myself thinking faster and keeping focus all the time!

  • @dhavalnena7386
    @dhavalnena7386 Pƙed rokem

    Truly a Masterpiece explaining whole life cycle of a small project. Much appreciate your efforts.. Thank You Sean!!

  • @KimbrellBrad
    @KimbrellBrad Pƙed 3 lety +2

    Oh Man! So timely for me.I have been wrestling with how to plan what goes into my VM or not while doing my coding. This process of getting it working first and then worrying about how to put it into the proper structure at the end really opened my eyes! Perfectly logical but when starting from scratch it was not so obvious to me. I always expect top-notch content from you and your courses but this one hit me right between the eyes! THANK YOU!

    • @seanallen
      @seanallen  Pƙed 3 lety

      When I was building this video, I knew there was a lot of good nuggets in here. Happy to hear it helped with your ViewModel questions! Glad you enjoyed it.

  • @rungxanh2901
    @rungxanh2901 Pƙed 3 lety +3

    This tutorial is clearer than crystal. Thank you very much for this portfolio project Sean đŸ™đŸ»

    • @seanallen
      @seanallen  Pƙed 3 lety

      Thanks for the kind words, Joe. Happy to hear it was easy to grasp.

  • @RatherBeCancelledThanHandled

    Beautifully explained and executed ; well done !

  • @SuperJDParker
    @SuperJDParker Pƙed 2 lety +1

    Enjoyable tutorial. Your concise, to-the-point instruction style, as well as your enthusiasm, adds value to your presentations. I liked learning more about the map(_:) method and about alert processing. Best of luck in your iOS dev courses.

  • @ahmadwaqas6044
    @ahmadwaqas6044 Pƙed 3 lety +2

    Another great piece of awesomeness like always. Thanks Sean 💕

    • @seanallen
      @seanallen  Pƙed 3 lety

      Thanks for the kind words, Ahmad 👍

  • @user-pb1ng9wz1l
    @user-pb1ng9wz1l Pƙed 2 lety

    It's an amazing video!
    Maybe it's hard to understand for programming rookies.
    But the step-by-step teaching makes more clear to know how to build an app.
    NICE WORK!

  • @Omeir34
    @Omeir34 Pƙed 3 lety +2

    Always eager to watch your videos!

    • @seanallen
      @seanallen  Pƙed 3 lety

      I appreciate that, Omair 😀

  • @semilife
    @semilife Pƙed 3 lety +1

    Thanks Sean for another quality video. Practical, concise and real world. Great engaging teaching style, learning lots, keep up the great work. You are one of a few who are pushing out great regular and up to date iOS stuff. Many thanks.

    • @seanallen
      @seanallen  Pƙed 3 lety

      Thanks for the kind words 😀

  • @naqeebahmed7113
    @naqeebahmed7113 Pƙed 3 lety

    this is really a great video learning swiftUI and MVVM. I really appreciate your initiative to start portfolio projects because it really help us guys beginner and intermediate to learn new thing, building small apps.

  • @timmy53driver
    @timmy53driver Pƙed 2 lety +1

    Awesome video! Very clear not too much jargon to confuse we newbies. The refactoring section was the most useful. How to refactor lessons are scarce and yours made the process very clear and easy to adapt to any project. Thanks for your effort and time to share your knowledge.
    Timmy!

    • @seanallen
      @seanallen  Pƙed 2 lety

      Glad you enjoyed it, Timmy!

  • @ruptapas
    @ruptapas Pƙed 3 lety +2

    Very nice Sean loved every bit of the process of this tutorial...

    • @seanallen
      @seanallen  Pƙed 3 lety +1

      Thanks Ruptapas! I'm experimenting with longer, more in-depth tutorials so the feedback is appreciated.

  • @jeffreyslater4416
    @jeffreyslater4416 Pƙed 2 lety

    Những ca sÄ© khĂĄc cho mĂŹnh cáșŁm giĂĄc thÆ° giĂŁn khi nghe! CĂČn ĐP luĂŽn cho mĂŹnh bị cuốn theo tinh tháș§n bĂ i hĂĄt.

  • @GabrielBrodersen
    @GabrielBrodersen Pƙed 3 lety +1

    Thank you once again Sean!

  • @w0mblemania
    @w0mblemania Pƙed 3 lety +1

    Excellent video, Sean. Thanks.

    • @seanallen
      @seanallen  Pƙed 3 lety

      Thanks! Glad you enjoyed it.

  • @khoiho3765
    @khoiho3765 Pƙed 10 měsĂ­ci

    Thankyou!, this was very helpful

  • @kaideumers6102
    @kaideumers6102 Pƙed 3 lety +2

    Great tutorial! Really learnt something today

    • @seanallen
      @seanallen  Pƙed 3 lety +1

      Glad to hear it, Kai 😀

  • @consumer8592
    @consumer8592 Pƙed 3 lety +1

    thank you for your knowledge and your time!

  • @Cillitbaaang
    @Cillitbaaang Pƙed 3 lety +1

    Thanks bro! Learned a lot. Keep up the good work - maybe more of those longer vids!? 😉đŸ’ȘđŸŒ

    • @seanallen
      @seanallen  Pƙed 3 lety

      Glad you liked it! I plan on doing more of them. However, they take a TON of time to create. So it'll be like once a month or something like that.

  • @SBSanook
    @SBSanook Pƙed 3 lety +4

    Very nice! Perfect length - I prefer the longer but more in depth videos, and this one felt way faster than 1:18. I like seeing the thought process and steps involved, too, particularly the refactor process. Seems obvious, but I always end up refactoring everything at once, rather than step-by-step shown here. Thanks!

    • @seanallen
      @seanallen  Pƙed 3 lety +1

      Thanks for the feedback on the longer video, Scott. I rarely do these long videos, but it's something I'm experimenting with and will sprinkle in from time to time. Glad you enjoyed it!

  • @zeryez6347
    @zeryez6347 Pƙed 3 lety +1

    Great Video thanks for all the effort you put into that really learned something👍

    • @seanallen
      @seanallen  Pƙed 3 lety

      Happy to hear you appreciate it! That one was a lot of work and while I was building it I said to myself "there's a lot of good stuff in here". Glad to see others getting value from it.

  • @Collins01
    @Collins01 Pƙed 2 lety

    I am coming from a flutter background , i decided to try Native IOS. Your Tutorials are the best, Thank you very much. I have learnt a lot.❀

  • @zainhaider6628
    @zainhaider6628 Pƙed 2 lety +1

    20:10 you can use if moves[i] != nil { return }

  • @chupapimunanyo2596
    @chupapimunanyo2596 Pƙed 11 měsĂ­ci +1

    I love your way of teaching. As a computer science student who has background in other programming languages, diving headfirst into a new one (swift) by watching this is just so much better than watching a series of the basics about swift!
    You don't need to learn how variables and functions etc. work in swift because HERE: you just learn that on the fly while directly seeing, how different functionalities of swift can be put together in a real world exaple (ok it is tic tac toe but still... :D )
    A little improvement suggestion: If these kind of videos are ment for beginners, it may be helpful to cover unique details of swift syntax like the dots or the keywords "in", "for" used in functions. I think this is a swift thing since I have never seen something similar and I had to ask ChatGPT over and over again what these little things concretely do 😀

    • @seanallen
      @seanallen  Pƙed 11 měsĂ­ci +1

      Glad you enjoyed the tutorial. This was meant for non-beginners as it's designed to be a project someone looking for their first job might put in their portfolio. I appreciate that feedback!

  • @kalinbalabanov1013
    @kalinbalabanov1013 Pƙed 3 lety

    All your videos should be like this :D

  • @dwikurniawan1376
    @dwikurniawan1376 Pƙed 2 lety +1

    I love your teaching style. very concise and easy to understand

  • @a4advanture755
    @a4advanture755 Pƙed 3 lety +1

    thanks Sean Allen i enjoyed your video . you are the best while during code you have some jokes >> a lot of love

    • @seanallen
      @seanallen  Pƙed 3 lety

      Glad you enjoy the videos, Sikandar!

  • @jazz_devk1
    @jazz_devk1 Pƙed rokem

    Thank you!

  • @laurapotter6321
    @laurapotter6321 Pƙed 2 lety

    thank you so much!!

  • @nitinrane6226
    @nitinrane6226 Pƙed rokem

    Nice video and like your teaching style

  • @boebra2276
    @boebra2276 Pƙed 2 lety

    Thank you so much đŸ™đŸ»

  • @mandcali7613
    @mandcali7613 Pƙed 10 měsĂ­ci

    When the centerSquare is a circle4 :). Thanks for the learning though. Nice video.

  • @yoellev5191
    @yoellev5191 Pƙed 3 lety +3

    Sean is on fire đŸ”„đŸ˜œ

    • @seanallen
      @seanallen  Pƙed 3 lety

      I took a 3 week break, so I was ready to get back at it 😀

    • @yoellev5191
      @yoellev5191 Pƙed 3 lety +1

      @@seanallen Yep I know the feeling, we do need this break from time to time. Always happy to get a notification from your channel đŸ’ȘđŸŒđŸ€™đŸŒ

  • @nelan3334
    @nelan3334 Pƙed rokem +1

    As an experienced developer in other tech (Android) I appreciate your pace! I struggle with other tutorials feeling I am loosing a lot of time, so I am really grateful that I have found this one!
    I have only one objection (or question) : shouldn't ViewModel be free of stuff from swiftUI (like GridItems)?
    If I would do this in Android, I would leave in view all UI parts of the code.
    Other that that, I congratulate you on awesome job with this series!

  • @markaurelius61
    @markaurelius61 Pƙed 3 lety +1

    I like the way you wrote checkWinCondition. I was using arrays and loops ( I had exactly the same order for winPatterns though)

    • @seanallen
      @seanallen  Pƙed 3 lety

      Thanks, I also enjoyed that when I was building. My initial thought was loops, but then working with sets came to mind and I felt that was better.

  • @Engjeanluiz
    @Engjeanluiz Pƙed 2 lety +1

    Amazing !!!!!

  • @TheDirection.
    @TheDirection. Pƙed 3 lety

    just finished. interesting

  • @simonIsDev
    @simonIsDev Pƙed 3 měsĂ­ci +1

    It's pretty cool

    • @seanallen
      @seanallen  Pƙed 3 měsĂ­ci +1

      Glad you liked it :)

  • @christiansimbarashe
    @christiansimbarashe Pƙed 3 lety +3

    I'm already know I'm going to like this 3 minutes in

    • @seanallen
      @seanallen  Pƙed 3 lety

      That's awesome to hear! Let me know what you think at then end.

  • @boredbytrash
    @boredbytrash Pƙed 2 lety

    Great session! I like the refactoring part! I advice any software engineer to at least read about the principles of clean code. That big method that processes the moves of the player and computer could’ve been easily split up so each method is just doing ONE task and not multiple. With precise method/function names, comments get obsolet.
    Great tutorial and thanks for sharing such an in-depth look into TikTakToe SwiftUI development.

  • @nunomanuelsousa6660
    @nunomanuelsousa6660 Pƙed 3 lety +1

    Excellent presentation of how to create a game with some intelligence :-)
    Congratulations... 5 *

    • @seanallen
      @seanallen  Pƙed 3 lety

      Thanks for the kind words, Nuno. I appreciate it!

  • @nattawootsamakhom5805
    @nattawootsamakhom5805 Pƙed 3 lety +1

    How to make a user login screen? Can you make a video about it? It would be very helpful for those who needed. Thank you 🙏

  • @gregohb
    @gregohb Pƙed 3 lety

    How else would you refactor? There are a couple of structs at the bottom of the main view controller - move those to the class too?

  • @jaymartinez311
    @jaymartinez311 Pƙed 3 lety

    I thought you were quitting doing videos in programming and focusing on the financial stuff i think you said in the passed. Caught this video late but it’s definitely good to see pop up. Great video and i like the longer videos. Hope to see more like it. You were the first swift channel i followed and swift is now my main language. Appreciate you and i wanted to ask if you were going to add more content to your course on teachable(which i own) or are you coming out with a more advance course? đŸ€”

    • @seanallen
      @seanallen  Pƙed 3 lety +1

      Happy to hear you enjoy the larger videos. I have an intermediate SwiftUI course coming out in a week or so. As for the finance channel, that will be sometime after WWDC and will be a side project to the iOS dev videos. I will do both.

  • @benhbr
    @benhbr Pƙed 3 lety +1

    Can‘t we instead of isSquareOccupied(i) just check whether moves[i] != nil ?

  • @femtechnology3055
    @femtechnology3055 Pƙed 2 lety

    This was an amazing video! Would you ever do one on how to build a quiz app?

    • @seanallen
      @seanallen  Pƙed 2 lety +1

      I have a VERY long video idea list 😀. That's on it... just not sure when it will happen.

    • @femtechnology3055
      @femtechnology3055 Pƙed 2 lety

      @@seanallen Totally! Makes sense! Such a shame that there don't seem to be any SwiftUI tutorials on how to create a MC quiz

  • @gregohb
    @gregohb Pƙed 3 lety

    Super interesting and useful. I learned a number of things. One question - why am I not seeing the extract view at 1:13)? Also its hard to type along when you jump to different parts of the screen. by the time I stop the video with 5 second delay, then its a hassle to catch things at time. But I appreciate your effort here.

  • @BeetMasher
    @BeetMasher Pƙed rokem +1

    idk if I'm missing a point here but it seems kinda weird to me to determine the move position by rolling a dice until the result is not already occupied. Wouldn't it be more efficient to create a new array of all positions that are not already occupied and then selecting a random position from that array? Anyways, thanks a lot for the great tutorial, I really enjoyed it!

  • @NachoSotoBustos
    @NachoSotoBustos Pƙed 3 lety +2

    You can avoid some repetition by using do/while instead of while.

    • @seanallen
      @seanallen  Pƙed 3 lety +5

      Great point, Nacho! Thanks for pointing it out (genuinely). There are certainly plenty of places my code can be improved. I noticed a lot of them while editing. However, after 2.5 hours of filming and another 4 hours of editing... I just let them be 😀.

    • @NachoSotoBustos
      @NachoSotoBustos Pƙed 3 lety +3

      @@seanallen great video though! Not easy to put out all this code out there for thousands of people to code review.

    • @seanallen
      @seanallen  Pƙed 3 lety +2

      Thanks! I've gotten used to that over the years. Thankfully, 99% of the "code review" type comments are done in a cool manner so I actually learn a lot from them.

  • @MathyosSarkiss
    @MathyosSarkiss Pƙed 2 lety

    Thanks for the great videos...I have a question, how do you keep track of the Swift tricks like the array. contain where put $0? I'm a c++ program i can easily think of doing it as if moves[i] != nil

  • @douglascf2
    @douglascf2 Pƙed rokem

    Nice video! However your ViewModel must never be aware of SwiftUI!

  • @markph0204
    @markph0204 Pƙed 3 lety

    I love learning --- suggest that moves[index]?.indicator != inside isSquareOccupied() would be more efficient and simplifies the learning curve for new programmers, no?

  • @laigvk
    @laigvk Pƙed 2 lety

    AčiĆ«!

  • @marijkehagemans4332
    @marijkehagemans4332 Pƙed 3 lety

    Hi Sean, thanks for the great tutorial. I have been playing with refactoring my swiftui project to MVVM too. In your video I am missing the model part. What would you put in the model ?

    • @seanallen
      @seanallen  Pƙed 3 lety +1

      For this specific app (Tic Tac Toe) - the Move object as well as the Player enum could be considered the part of the Model. If you were asking about you specific project, that's tough to say as I know nothing about your project. In general the Model should be your objects. In the Tic Tac Toe example, the Move is one of our objects.

  • @leonardadrian1173
    @leonardadrian1173 Pƙed rokem

    just saw your videos of recent its really a break through..

  • @carissarichardson9867
    @carissarichardson9867 Pƙed rokem

    could you do a video using Uikit for tic tac toe? I have already I just want to see a Professional

  • @williamsquires3070
    @williamsquires3070 Pƙed rokem

    I didn’t like this implementation, so I added another case, “empty” to the “Player” enum. Now, I can initialize the entire board[] array with Move instances with no nils in it, so:
    @State private var board: [Moves] = Array(repeating: Move(player: .empty, boardIndex: -1), count: 9)
    Now I don’t need nil coalescing, or optional unwrapping, so changed the line:
    Image(systemName: board[i].indicator) by getting rid of the “?”.
    and changed the computed property getter for struct Move to:
    var indicator: String {
    let result = (player == .human ? “xmark” : (player == .computer ? “circle” : “”))
    return result
    }
    Finally, my onTapGesture is now:
    onTapGesture {
    let aMove: Move = Move(player: isHumansTurn ? .human : .computer, boardIndex: i)
    if board[i].player == .empty {
    board[i] = aMove
    isHumansTurn.toggle()
    didPlayerWin()
    }
    }
    which calls a method I wrote called, “didPlayerWin()”, which checks each row and column, and the two diagonals to see if they’re filled with either .human or .computer and prints an appropriate message to the console (for now). If no row, column, or diagonal is filled, it checks to see if all the board has been filled (i. e., no cell contains .empty) and prints “Tie”, else it prints “Game still in progress.”
    Sadly, my implementation of didPlayerWin() is far too long to print here, and involves two other helper functions which I also wrote, “check3squaresForX()”, and “check3squaresForO()”. I’ll leave to your imagination as to what these do. 😉

  • @mrskiutah
    @mrskiutah Pƙed 2 lety +1

    Great tutorial. Thank you! Why write an isSquareOccupied function that scans the moves array? Couldn't you just check if moves[i] != nil?

  • @mikeysplayhouse1971
    @mikeysplayhouse1971 Pƙed měsĂ­cem

    Moving variables to the 'GameViewModel and declaring them Published was a breaking move for me. Maybe it's a version issue?

  • @khaledannajar
    @khaledannajar Pƙed rokem

    Are you going to make other projects like this?

  • @hananalshammari5127
    @hananalshammari5127 Pƙed 3 lety +1

    if let move = moves[i] {
    Image(systemName: move.indicator)
    .resizable()
    .foregroundColor(.white)
    .frame(width: 50, height: 50)
    .font(.title)
    }
    consider this to get rid of the warning saying no systemName in Sf called ""

  • @James-pj6cg
    @James-pj6cg Pƙed 2 lety

    @ 52:35 is it "best practice" to move the isGameboardDisabled = true or put isGameboardDisabled = false in the resetGame function?

  • @_thekick3r
    @_thekick3r Pƙed rokem

    I get an error saying *"Cannot convert value of type '[Move?]' to expected argument type '[Move]"* at the checkWinCondition part for the human. Please help me.
    if checkWinCondition(for: .human, in: moves) {
    print("User wins")
    return
    }

  • @hananalshammari5127
    @hananalshammari5127 Pƙed 3 lety

    determainComputerMove will go on infinite loop after the last tapped square

  • @lakithjayalath9411
    @lakithjayalath9411 Pƙed 3 lety

    When developing a game (may be a 2D game or fun little game like you developed in this video) do you think it is better to use SwiftUI or spritekit. I am new to swift and have only played around with UIKit and I'm planning on learning SwiftUI or spritekit for a game I'm thinking of developing. What is your suggestion? Is it possible to make a good game using SwiftUI?

    • @seanallen
      @seanallen  Pƙed 3 lety +1

      This really depends on the game. Simple games like tic tac toe are probably fine in SwiftUI. But the more serious the game, you're probably better off with a game engine.

    • @lakithjayalath9411
      @lakithjayalath9411 Pƙed 3 lety

      @@seanallen Got it.Thanks.

  • @AniMV-Channel
    @AniMV-Channel Pƙed 2 lety

    .alert(item:content:) will be deprecated in future version of iOS

  • @markph0204
    @markph0204 Pƙed 3 lety

    Extract Subview is gone in Xcode 12.5 for me, but you also used same...? :(

    • @markph0204
      @markph0204 Pƙed 3 lety

      I found the issue -- command line tools was not properly set. This made *some* refactoring options not visible in project!

  • @jamesreal3713
    @jamesreal3713 Pƙed rokem

    Code you did this in UIKit?

  • @andryo59
    @andryo59 Pƙed 2 lety

    How to align equal signs like in 45:55?

    • @seanallen
      @seanallen  Pƙed 2 lety

      I manually tab them over. It's extra work, but in my opinion makes the code more readable.

  • @AmCanTech
    @AmCanTech Pƙed 3 lety +1

    open source??

    • @karljay7473
      @karljay7473 Pƙed 2 lety +1

      If someone does something like this on CZcams, it's automatically open for anyone to use. You're probably looking for a repo of the source. I haven't found one. I'm typing it in myself. It might be disrespectful to Sean to post the code without asking, it could be a part of his business plan, so I won't post without asking and I don't have the completed code yet.

    • @AmCanTech
      @AmCanTech Pƙed 2 lety

      @@karljay7473 Agreed, it's a tutorial at the end of the day

  • @davidruvinskiy6347
    @davidruvinskiy6347 Pƙed 3 lety

    Hey Sean thanks for the video. Haven’t watched all of it yet, but I know it’s going to be awesome. It’d be really cool if you could take the AI one step further with something called the Minimax algorithm: www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-3-tic-tac-toe-ai-finding-optimal-move/amp/.
    I’ve always wanted to implement the algorithm in Swift but could never figure out how since it involves some pretty complicated logic. Thanks!

    • @seanallen
      @seanallen  Pƙed 3 lety

      I believe this would make an unbeatable AI tho. A game of tic tac toe should never be won if both players are making optimal moves. I kept my AI algorithm relatively simple for two reasons.
      1. Ease of understanding for people early in their learning journey. Like you said, making that unbeatable AI gets pretty complicated and I didn't want to lose people.
      2. I wanted to allow the AI to make mistakes so that it could be beat.

    • @davidruvinskiy6347
      @davidruvinskiy6347 Pƙed 3 lety

      Sean Allen Gotchya. No worries. Also, do you think you can include a link to the completed project?

    • @seanallen
      @seanallen  Pƙed 3 lety +8

      I'm still thinking about that. I want to avoid people just downloading the project, putting it on their Github and saying "Cool, here's a free portfolio project". Maybe I'm being too negative, but I want people who actually went through the video and learned stuff to have the reward of the code.

    • @TechRagh
      @TechRagh Pƙed 3 lety +1

      @@seanallen Absolutely, đŸ™ŒđŸŒ

    • @rungxanh2901
      @rungxanh2901 Pƙed 3 lety +1

      @@seanallen I second this âœŒđŸ»

  • @hrajput4
    @hrajput4 Pƙed 3 lety

    Is this really an AI solution?

    • @seanallen
      @seanallen  Pƙed 3 lety

      It's an insanely basic decision-making one, but by definition... yes. I used the term "AI" mostly to communicate in the title that we will be programming the game to take actions based on the human moves.

    • @karljay7473
      @karljay7473 Pƙed 2 lety

      There could be debate about this, but I always heard that it has to improve itself over time. I'm not sure where I got that from, but it's one of the things that I've heard in the past. It needs to be able to learn from what it's done in the past and improve upon that over time. AI really isn't well defined, or at least I find different definitions. Having said that, this is a great tutorial, love that Sean has embraced SwiftUI.

  • @petitcomiteparis6685
    @petitcomiteparis6685 Pƙed rokem

    Thank you for your Tutorial! I was coding, till the point -to the new folder and copy from GameView to GameViewModel.. Than I was lost 😧because can't fixed all the error lines like you! So I was go back with command and Z but all was lost đŸ„ș...đŸ˜© because I did clean so much from -my on mistakes and was so happy and proud ,till this FukkNewFolder 😿 This Tutorial did stressed me so much because my Xcode makes so many redlines. Maybe I did code on this 10 hours without result đŸ€ĄNext time always copy all that shit I did do on an safe place !❀‍đŸ©č (P.S.) I'm beginner and this was my first App till 13 min. to the end of this Tutorial! All other Tutorials I did was always the problem this I can't fix my mistakes or bugs in Xcode. Its so hart to learn alone, im sad and happy, im frustrated and motivated, im in love and make it again but need now pasta Best reagents from Berlin sorry for my bad english đŸ‘» much love 🩄