Friday, December 21, 2012

Github, Python, and Baseball

Github Account! With stuff!

I have recently updated my Github account with something other than the non-trivial (although needing some clean-up) slideshow django-cms plugin. Maybe it's kinda trivial too, but it was fun :)

https://github.com/mcneo

A long time ago I mentioned that I wrote a baseball simulator that helped me correctly gauge the abilities of hitters in baseball using their Plate Discipline metrics. It worked, although the power numbers were wrong. I have cleaned it up a ton, mostly to match PEP 8 coding standards. I still have plenty of things I could do to improve the accuracy of the code; primarily by removing BABIP (batting average for balls in play) from the equation and using Line Drive, Ground Ball, and Fly Ball rates instead. That will at least divorce my code from those statistics that take longer to stabilize (BABIP mostly *doesn't* stabilize -- unless you are Ichiro Suzuki).

+Nathan Sanders You asked for this like 3 years ago :) I finally delivered.

Tuesday, September 11, 2012

Upcoming Projects and Stuff

I have a ton of stuff I'm really excited about working on. I'll try to keep this blog updated so people can keep up with me, now that I've got some free time.
  • My Web site (rather than just being a redirect to Blogger)
  • A Web site for Mike Bliss (the magician)
  • A health Web site
  • Python baseball sim
  • Learn Groovy
  • Implement a half dozen different design patterns using javascript, and make them available on my Web site

Load Speed

Something often overlooked by people outside the web development industry is page load speed. Plenty of people know it's importance, but yet, it often takes a back seat to presentation on Web sites. I'm not going to focus on why it takes the back seat, that would require too many words for a Tuesday. I just want to highlight one of the things I was striving for in my last project.

My last project.* It was a really inexpensive Web site for a small business. One of the items I discussed with the owner of the company was price, and there was no money in it for a designer. Normally, I wouldn't be willing to work on such a site, but I made an exception. I rationalized the time I was going to spend on the project as having the opportunity to really bake a template into Django-cms. You can see the finished project here: jlong.jeremymcneal.com.**

*Not in the final sense, I'm working on some new stuff already. When I retire, I'll still be programming, it's one of my favorite past times.

** There are some odd content things on this site. Ignore those, this isn't the final version.

The template I utilized has absolutely 0 images on it. The files required to download and display the page are under 80k, and 70k of that is jQuery. And when I compress that, I'll be down to under 60k.

it's great to have Web sites that look pretty. But page speed is often under-rated; and often more critical to making a Web site a success, as opposed to just an art piece. Often, if you're doing good work with your css; your site can still be aesthetically pleasing as well as successful.

Warning: Don't get caught up in the details too much. Remember what the purpose of your site is, and focus on how you can best spend your time to improve it's (hopefully) track-able success.* You can be doing everything else right on a site, but if your not doing this on your site, you are wasting your time.

*Google Analytics

Note: it's been awhile since I've written a post, and blogger has really improved their interface.

Please leave a comment. I <3 comments.

Saturday, January 7, 2012

How to win at Tic Tac Toe

I couldn't sleep the other nite. As a result, I ended up thinking about the strategy of Tic Tac Toe. There really isn't a whole lot to think about, but in my head I went through all of the possible game states. Not a difficult feat since the game is both vertically and horizontally symmetrical. In the end, I was able to distill it down to a few basic principles. The center is the most valuable resource in the game. Always go for that. It is part of 4 possible ways to win. Next are the corners. Each of them are part of 3 possible ways to win. The middle outside spots are the worst. They are only able to help you win in 2 ways.

3 | 2 | 3
2 | 4 | 2

3 | 2 | 3

In practice then, if you are the X then you should start the game by taking the middle. If you don't you are likely to lose. The "O" player should then take a corner. If the "O" player takes a middle outside square, then the "X" player should take the corner square next to the spot taken by the "O" player. The "O" will be forced to block the potential cross victory position. The "X" player can now take a middle spot that connects his other two "X" spots, which will create a dual possibility for the win. He can also take any remaining corner spot for a dual win option on the next play.

If the "O" player is wise and takes a corner spot, the game is probably a draw. Almost any move from here creates a domino effect of blocking moves. It should be a draw. However, if the "X" player takes the opposite corner spot, then the "O" player has plenty of choices where the outcome isn't obvious. If they take an adjacent middle outside spot on the next move, then the "X" player may have to block an "O" victory, however the blocking will create the dual win situation for the "X" player. If they take any other middle outside spot, then the "X" player can setup the dual victory as well by taking the most open corner location.

The game does have a few non-obvious traps. If you are the "X" player you CAN win even against a more seasoned player by thinking about the game in terms of spot values.