Tic tac toe: Day 2

Today felt slow but when I look back on it it wasn’t all that bad. In the morning I added marker placing, database updating, turn switching, and win and tie detection with board disabling, which got me a fully functional human vs human version of the game. It took me most of the afternoon to get a really rudimentary AI implemented. Writing the AI itself took all of a couple minutes because it’s so simple (just chooses squares based on a ranking system with no regard for where the other player has played). Figuring out which variables needed to be passed to what parts of the AI and keeping getting everything called in the correct places took most of it.

Then we had a guest speaker who was pretty good. Almost all of them so far have said one of the biggest things they look for is people who are insatiably curious and avid learners which is encouraging since half the reason I’m looking to get into this field is because there’s always something more to learn.

After the official day was ended I was able to get back to the project and set it up so that the AI can be set to either player, and that’s where I’m at for now. Tomorrow I finally get to work on the smart AI!

Tic tac toe: Day 1

I spent all morning fiddling with CSS and bootstrap stuff. I created the game grid using bootstrap so it would scale and look nice from mobile all the way to desktop. It ended up taking a lot of work because setting a height that scales with width is not built in and I had to do a couple CSS tricks just to get that to work, then it would break when I put in x’s or o’s so I had to take them out of the document flow. Then came the tricky part. I needed to set font size to scale with square height and line height to scale based on font size so the centering wouldn’t break. The first part wasn’t bad, but centering with line height didn’t seem to scale in direct relation to font size so I had to center things at a few different spots to get data points and then do a linear regression to find the relationship. I think it will change based on what fonts and characters you are centering but this should point you in the right direction: Include the following in your JavaScript file (requires jQuery).

var resize = function() {
   // Set font size to scale with square height
   $('.class-to-scale-font').css('font-size', $('.square').height()*1.06)

   // Set line height to scale with font size so centering doesn't break
   $('.square').css('line-height', 0.75*parseInt($('.board').css('font-size'))+'px')
}

Then I  tweaked the navbar to scale a little better and set up some of my base Javascript. So progress was slow, but what I have so far is pretty solid.

Tic tac toe: Day 0

I’ve been so absorbed in my programming stuff I haven’t made time for updates, but I’m doing my first actual project now and I thought it would be fun to do a thought dump at the end of each day to see how it progresses and so I can go over it and see what improvements I can make to my approach.

So, Day 0.

I spent most of the day working on a game for an earlier assignment while I waited to talk to the head instructor to get feedback on my project. I said “unbeatable tic tac toe, player vs player if the AI is too hard, and multiple difficulty levels and fancier interface if it’s too easy.” He said “ok, and look into minimax for the AI.” So I did, and it’s going to be a lot harder than just taking every case into account (which would be very doable because the total number of games for tic tac toe is is a relatively low 26,830), but it’s the right way to do it. This way will essentially assign a score to each situation and then check possible future sequences to find the best move. The AI will be much more flexible because I’ll be able to tell it how many moves ahead to search and assign different scores for different situations.

So I spent most of the afternoon learning about minimax, game theory, and of course playing some tic tac toe. Then hashed out a couple ideas for page layout and that was it. Tomorrow the code writing will start.

Many happenings

I’ve been up to a lot of stuff and haven’t been blogging but i’m attending RefactorU now and I think it would be really helpful to capture some thoughts to help me work through problems, see progress, and give other people an idea of what a programming boot camp is like. Double thanks to Richard Lucas who is both letting me crash on his couch right now and suggested reviving the blog. i’m hoping to find time to post regularly, we’ll see how it goes.

I just finished Day 2, and it feels like we’ve covered a lot of ground already. I’ve been impressed by how well thought-out the course is. The format is kind of back and forth between lecture and coding and they give you a lot of stuff to try before giving you all the answers which has worked really well for me, making me think hard and keeping me engaged. The first real problem we were given was a CSS card flip exercise that I liked a lot because it was a cool trick, had a surprising amount of layered challenges to get working, and had a fairly elegant solution in the end. You can the code for my version here.

We also do a fair bit of discussion in peer groups, and something that came up that I thought was good was balancing trying to figure things out on your own and asking for help. The balance is important because getting stuck on one little thing for an hour is counter-productive but asking for help every 2 seconds isn’t going to solidify ideas the way working through it on your own will.

I’ve got stories from traveling and getting immediately kicked out of my apartment too, but those will have to wait because I need sleep.

HabitRPG

Continuing the theme from last time, I’d like to share a cool little app called HabitRPG. It turns your life into an RPG, leveling you up and giving you gold for accomplishments, taking hp when you fail to get stuff done on time, and allowing you to buy rewards for yourself. Its strength and weakness is that it is completely dependent on the user to set up the tasks and rewards which means that it’s wonderfully customizable but there’s nothing to prevent you from setting it up to be really easy and therefore not that helpful.

I’ve found it surprisingly helpful. Apparently keeping that 20 pixel high character alive is more important to me than prioritizing my life. Confounding, but it’s made this probably the most useful tool I’ve found so far.

Getting things done

I haven’t been satisfied with how much I’ve been getting done lately so I’ve decided to figure out a better approach. I did some research then talked with a couple friends and decided to make a big list of all the stuff I’ve found and want to try. Here is the current incarnation which you should definitely check out:

https://workflowy.com/shared/83c4aaf1-3c96-031b-0d7a-4c0a918bb88f/

Some cool tools that deserve specific metion: workflowy, the web app I made the list with, is super cool and I recommend it. Having someone or at least something to hold you accountable seems key, and NerdFitness provides a community and some tracking tools for that.  There are also tools to hold yourself accountable like iDoneThis which is tracking tool that reminds and encourages you to keep going.

If you have input or suggestions, things that have worked for you, please share. I’m always looking for more ideas.

A game to make you smarter that actually works

A game to make you smarter that actually works.

I was on one of my usual self-improvement article binges tonight when I stumbled across this game. There are lots of games out there that claim to keep your brain sharp but this one supposedly has peer-reviewed research supporting the claim (I say supposedly because the link was broken so I couldn’t read the original paper). All I can promise you so far is that it’s hard. I’ve never been terribly good at memory games but to me each level seems a lot harder than the last, and 3 is kind of kicking my butt right now.

On a side note, what I was really looking for is actual trainable or implementable solutions (not “tips”) for staying on task. Practitioners of mindfulness meditation claim it is the answer to inability to focus, but if so that still leaves the problem of procrastination or simply wasting time. Feel free to comment with suggestions.