don’t use the force Luke.
because your Jedi powers are too weak right now. I now have an even greater appreciation for non brute forced coding solutions. I’ve been working on creating an unbeatable tic tac toe for the past few days. Initially I started off building a 2 player game, which later turned out to be a 1 player game against a beatable computer, which must now be turned into an unbeatable game of tic tac toe. Yeah. Conceptually speaking, the challenge isn’t that bad. Oh, so I’m doing this challenge for two companies, and despite being given the option to do it in any language, I really want to work on my JavaScript. I’ll admit, that I’m probably being a bit stubborn or making it hard on myself my choosing JavaScript first rather than Ruby, but I’ll say that I’ve been learning a lot in the process which is the point of coding challenges anyways. I’ve learned about using the Javascript every and map methods which ar e pretty similar in concept to Ruby’s enumerable methods, how to set a default value for a variable using a snippet like this: fakeTurn = typeof(fakeTurn) == 'undefined' ? 1 : fakeTurn;
..and a bunch more. One thing I struggled with initially was handling different states of the tic tac toe board - more on that later when I actually get the miniMax algorithm to work. Turns out that JavaScript doesn’t handle cloning too well. Either that, or it’s a bit tricky to do deep cloning in JavaScript. One of my teachers at Dev Bootcamp pointed me towards using Object.assign( ) in order to make a shallow clone of an object/object property, which also led to me figuring out that I could use an Array.slice( ) in order to clone the array of my Game object that could be manipulated and NOT end up altering the original game board. Any who, I have a lot more to do today. Finishing up the ‘brute forced’ tic tac toe is on the list, but I’m pausing that cause I want to actually be able to look at clean code and really knock out the recursive solution. That, and I have to start preparing for more interviews and hopefully knock out Eloquent JavaScript pronto. Cheers to the weekend. Song: Tyler Touché - Act Of God ft. Jason Gaffne (Robotaki Remix) https://soundcloud.com/robotaki/tyler-touche-act-of-god-robotaki-remix-1















