I can’t believe I’m almost there – one more project to go to finish my front end dev certificate at FCC!
The Tic Tac Toe game was pretty challenging, and it took me a while to really figure out how to “think like a machine”, or rather, how to duplicate my own thinking by coding it out, so that I can actually use my code to win over myself.
I remember when I was a kid, I loved any kind of board games I could get a hold of, and when my parents were too busy to play with me, I would pretend to be my own opponent and play against myself — except it wasn’t nearly as fun as playing with an actual opponent. Well, not now! It was really fascinating that in the Tic Tac Toe game, a “machine” I devised could now beat me if I weren’t careful with my own moves … ! Machine learning/AI feels so tangible for the first time!
I got really stuck on this challenge because I made some really rudimentary mistakes (like misplacing the parenthesis in the “indexOf” statement, and couldn’t figure out for the life of me why my code wouldn’t run as I expected). Thankfully, I posted my confusion on the FCC forum and got help from several people – I was so thankful for their suggestions! It also took me some time to realize the right “strategy”, or logical steps, that a machine should take to win. After devising the right logical steps, the next stage was to think through all the variables involved in each click of a button, and how they may or may not change depending on how the buttons are clicked.
Most importantly, I was coding a function for each individual button, until someone on the FCC forum reminded me I could have written just one function, then make each button a variable. I changed my code entirely based on that suggestion, and saved so much time … ! How to think truly like a coder, that’s something I’m continuously grappling with.
This challenge was also particularly hard because I was in the middle of moving to a new place at the end of October, and was really stressed out at one point, by the expectation to finish my coding project by a certain “deadline”, and the realization that it might not be achievable. In the end, I was able to let go of the unrealistic “deadline”. After all, they say, there are no unrealistic goals, only unrealistic timelines. I think that’s so true.
I’m looking forward to my last front end challenge! By the way, you can view my codepen code here for this challenge.