Pacman Progress

I am nearing the end of my summer project. This is a clone of Pacman written in Java. I think I will stop implementing new features. Just clean up the code. Fix some bugs. Package the thing and call it a summer.

Recently I did a bad thing. I deleted all my Java files. I wanted to delete all my class files. That will teach me to try to compile from the command line. Damn. At least I had a backup that was a week or two old. It still irked me.

Some buggy object code had the game crashing when exceptions were thrown. Now we still need to hunt down the root cause of those bugs. However I managed to keep things running by validating parameters passed into my functions. Prevents evil access problems.

Next thing I might try to slip in there is better timing for the action in the game. Right now I just sleep a hard coded number of milliseconds based on how much processing I figured I expended to render a frame. However I really should just poll the clock to figure out how long to sleep.

Hot Technology

I read an article that surveyed what technologies Java developers were using. Hey. I want to keep up with the Jones. So I am keeping an eye on the top tech in a number of areas. I write them down here so I don't forget.

JUnit for testing.
Eclipse as your IDE.
MySQL or Oracle for the database.
Hibernate is your ORM.
MongoDB for NoSQL.
Jenkins for CI.
Maven to build.
SonarQube/FindBugs/Checkstyle for code analysis.
Nexus to hold artifacts.
Tomcat app server.
Spring MVC is your web framework.
Scala is your next language.
Java8 is coming up.

Okay. Time to get busy making sure I got these technologies under my belt. You got to work with the best, or at least the most popular. Shout out to the makers of JRebel, who I assume came out with the report ranking the technologies.

Wakka Wakka

This week we are taking our video game to the next level. The prototype works good. I decided to make a number of noteworthy additions, including sounds. I had used sampled clips before in Java. I even knew the libraries I needed to include.

So Pacman chomps on a pellet. The game is supposed to make this wakka-wakka sound. I got an audio file that has the sound. Just got to play it each time Pacman goes over a pellet. The first time I tried it out I heard nothing. I figured this could not be right. I played sounds before for my last game.

Then I looked at my game loop. For now we are settling for choppy animation until we get all the mechanics down tight. To prevent the game from running too fast, I sleep() for a second each iteration through the game loop. Turns out you cannot play a clip and sleep immediately afterwards. Drat.

When I finally implement the full animations, hopefully the sound will play fully. For now I just moved my sound playing earlier up in my game loop, giving it some time to execute before the thread sleeps. Next up my partner has to add more AI to make the ghosts "smarter". Currently Pacman can outsmart them and leave them lost.

MySQL Connector J

My latest project is an Amazon web page scraper. I have almost 5k eBooks in Kindle format. Every time I finish reading a book, I have a hard time choosing the next one to read. I do a lot of searches on Amazon to figure out which of the books I own is the next best.

I figured I should be able to let the computer choose a book for me. To do that, the computer needs to have a lot of stats on the books I own. Time to mine the Amazon web pages for those books to get the data I need.

So I am working on a scraper to grab the data I need from Amazon web pages. Then I plan to store this data in a MySQL database. With all the facts on hand, I am sure I can write a function that ranks the books in order from best to worst.

Writing the scraping portion turned out to be a big pattern matching exercise. Check. Next I need to store the scraped data in the database. I thought I had coded some Java that accessed a MySQL database. Turns out it was Java that accessed a Java DB.

No problem. How hard could it be. Well I kept getting exceptions stating that there was no suitable driver found to access MySQL using JDBC. Err it turns out I need the MySQL Connection J jar file in the classpath. Who knew?

Pacman Fever

I partnered up with a friend of mine from school to work on some projects together. At first we did some database web apps in PHP. Now we are getting to the real fun. We are writing a Pacman clone.

Now I believe in starting small. Therefore I got Pacman to be drawn to the screen. The guy chomped around a rectangle nicely. My friend took on the task to get a ghost drawn. It drew, but ran off the screen initially. Bugs have since been fixed and the ghost bounces around inside the boundaries.

Next step is to draw a rudimentary maze and have the Pacman and ghost obe the walls of the maze. I think we got this.

Custom Tools


I was called by my boss to work on a tough problem. The previous developer spent a week on it and got nowhere. Great. Now the pressure was on. I was given a day to figure things out. So I got down to business. Had to try many things to replicate the problem in a development environment.

Sometimes I needed to update configuration data in the database. Most of the time I had to run some queries to figure out which values needed to be updated. Or I needed to run some specific pieces of some jobs, which turned out to be stored procedures. I figured there had to be a speedier way to do all this.

There is a better way. Create a tool to automate what I need done. What better language to implement this tool than Java? Figured I would use the easiest database access method I could think of. That would be JDBC. Unfortunately the last time I played with JDBC, I used it with a MySQL database that was running on my computer. Now I needed to access an Oracle database running on some huge server.

Luckily most of the ideas in JDBC transcend specific database choice. Just had to figure out the connect string. Turns out I could use an OCI driver that made use of a TNSNAMES alias. That was sweet. Took a while to get it working though. The real breakthrough came when I read the release notes for my Oracle 11g client that was installed locally. Turns out I needed to ensure a JDBC jar file was in my classpath.

My initial cut was a little slow for each action. That's becuase I was creating and closing out a session every time a task needed to be executed. Instead I need to refactor this to reuse one database connection that gets established when my tool starts up. That should be an easy enough fix. I wonder whether it is time to share my little tool with the other developers on my team?

Right Tool for the Job

I am dealing with this game system that cannot handle too many views to the ranking system. Sheesh. What is a developer to do? Scrape the screens, reengineer the data, and put up some new pages. That's what. I already grabbed the HTML output from a bunch of ranking screens. Now I need to parse through the heavy HTML and extract the raw data. Java is my tool of choice for this task.

I got a bunch of files. And I have studied them to learn the pattern of how the web pages are laid out. Now I need to go through the HTML, line by line, and grab the raw data. Luckily each page seems to fit a pretty well defined pattern. I just need to teach my Java code to read for the data like my own eyes can now.

Heck. Maybe I will even write the new implementation using Java. The original product was written in PHP. I suspect they have a MySQL backend database. For my first try, I plan to grab the data and stick it in an Oracle database. However it could just as easily work with a MySQL database.

The only question is that once I have an optimized replacement system, what language will I use to serve up the data? PHP? Java? Or maybe something else. For now Java seems best. I actually don't know PHP. So that is a main consideration.