Shakes The Clown

Posted on 2010-06-17 19:02 in Blog • Tagged with entertainment

My coworkers have been beating on the movie, Shakes the Clown, for the past two months. Any time any one mentions something painful or movies in general, this movie comes up and they all agree that this is one of the worst movies ever made. So, I thought that I’d give it a try.

Luckily, Netflix had the movie available for streaming, so I didn’t have to wait long once I decided to watch it.

I’ve seen my share of bad movies over the years. In college, I was vice-present of the short lived (one semester) Bad Movie Club. We specialized in finding the worst of the worst, terrible, most painful movies in existence; and then watching them.  Shakes the clown, is NOT a bad movie.

The plot is a little weak. It follows Shakes, a clown, for a couple days.  The audience is introduced to his alcoholic life, we get to see his social connections breaking down and the troubles he has been having. The climax of the movie comes when he gets framed for a crime and he tries to turn his life around.  Story wise, everything flows nicely and the dialog is not over the top, with such great one liners as: “That was a lucky shot of whiskey”.

The visuals for the movie were really spectacular.  There was a dramatic contrast between the brightly colored clowns and the dull/ dusty background of the bar and their apartments.  I was very pleased with the wide variety of clowns pictured, old washed up loners, cross-dressing men, rough and tough rodeo clowns, and the standard neat colorful clowns we see at the circus.

Movie Grade: 3 Stars


Continue reading

JavaScript and Screen Responsiveness

Posted on 2010-06-01 23:38 in Blog • Tagged with javascript, programming

Lately, I’ve been playing around with JavaScript, creating a visualizer for my next AI game competition (in the fall?). I’ve decided to deviate from my past setup; instead of displaying live games on the over head, I will instead be recording player action to a log file and then replaying the results on the overhead. This log file can then be provided to the participant, allowing them a detailed look at all the steps their AI took during a sample game.

The problem I discovered involved the rate at which changes are painted to the screen.

$(".note").html("Message one");
sleep(5000); // example 5 second sleep routine  
$(".note").html("Message two");  

With the above code snippet, one would expect Message one to appear, be displayed for five seconds, and then get replaced with Message two. Instead, something surprising happens. When the script is run, no message appears, the page freezes for five seconds, and then the second message appears. The first message is never displayed.

The cause for this is quite surprising. It appears most browsers (the three I tested) wait until the JavaScript function has completed running before it starts updating the displayed page. I believe this was the case initially because the JavaScript interpreter and the page rendered ran in the same thread, so the two tasks could not be accomplished concurrently. Today, this behavior is probably maintained the same for backwards compatibility. I cannot fathom why this behavior would be written into a JavaScript specification, so that is probably not the culprit.

The fix appears simple, but can get quite complicated. JavaScript provides a time routine, that runs a function of your choosing during each timer tick. (JavaScript does allow for multiple timers to run in parallel)

var id = setInterval ( "desiredAction()",1000 );  
function desiredAction ( ){  
    // action code  
    if(lastAction){  
        clearInterval( id );  
    }
}

This is great if you want to perform the same operation for each tick, but in my case, sometimes I wanted to update text, other times move images. To solve this problem, as I parsed the log file, I queued up all the different events in an array. During the timer tick, I removed the first item in the queue and called the associated function pointer to perform the desired specific action.

function performEventQueueAction(){  
    // verify there are actions left  
    if(window.game.eventQueue.length > 0){  
        var action = window.game.eventQueue.shift(); // remove item in front of array  
        action.func( action.data ); // use function pointer with saved data  
    }  
    // stop rendering when actions complete  
    else{  
        clearInterval( window.game.eventInterval ); // stop timer  
    }  
}  

With this tasking, the page stays responsive because the event handler is available to respond to mouse clicks for browsing to the different portions of the page, and all the game display events occur in the order desired, in the approximate time desired.


Continue reading

Embedding Libraries in Java Executables (JAR)

Posted on 2010-04-18 15:43 in Blog • Tagged with java, programming

I’ve been working on developing a small Java utility for use at my place of work. The utility is used for parsing log files and extracting useful engineering data. Often, this work is performed out in the field literally in the middle of a desert] and most of the time the laptop they are using is handed to them as they are walking out the door to the test range. For this reason, the utility we’ve created has been designed to be as stand-alone as possible, requiring no install.

One of the most requested features is the ability to graph the change of a variable over time. The students on my team identified an open source graphing library that worked perfectly. The problem was we now had to ship two files to the test range, not much, but twice as many as before.

Solution

Using Netbeans we were able to modify the build process to embed the library inside the resulting Jar file. Place the following code in your build.xml file, modifying only the red text to match the name of the final Jar.

<target name="package-for-store" depends="jar">

<!—

http://java.sun.com/developer/technicalArticles/java\_warehouse/single\_jar/

Change the value of this property to be the name of your JAR, minus the .jar extension. It should not have spaces.

<property name="store.jar.name" value="MyJarName"/>

-->

<property name="store.jar.name" value="Bundled_JAR"/>

<!-- don't edit below this line -->

<property name="store.dir" value="store"/>

<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>

<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>

<delete dir="${store.dir}"/>

<mkdir dir="${store.dir}"/>

<jar destfile="${store.dir}/temp\_final.jar" filesetmanifest="skip">

<zipgroupfileset dir="dist" includes="\*.jar"/>

<zipgroupfileset dir="dist/lib" includes="\*.jar"/>

<manifest>

<attribute name="Main-Class" value="${main.class}"/>

</manifest>

</jar>

<zip destfile="${store.jar}">

<zipfileset src="${store.dir}/temp\_final.jar" excludes="META-INF/\*.SF, META-INF/\*.DSA, META-INF/\*.RSA"/>

</zip>

<delete file="${store.dir}/temp\_final.jar"/>

</target>

What’s happening behind the scenes?

Netbeans performs the following actions to build the final Jar. (Which you can do with a script if you feel so inclined.)

  1. Compile all source files to class files
  2. Extract all class files from library Jar files
  3. Compress all class files (include library files) into new single Jar file

Continue reading

Iceberg Races

Posted on 2010-04-12 22:03 in Blog • Tagged with competition, programming

On Friday night (April 9th), I held my second programming competition at NDSU. This year’s turnout was much better than last year.

The Game

Iceberg Races is you’re run of the mill racing game. Players control a car which they try to navigate through the race to complete laps. When the game starts, the players are sent a copy of the map, and during each turn, they are provided location and velocity details for all the vehicles on the track. The competitor’s goal was to write an AI to find the best path through the map to win the race.

Iceberg Races Screenshot

Participants

This year 22 people participated, including students from NDSU, MSUM, and Concordia. I believe all of the participants were undergraduates. All competitors came in blind. The only details that were released about the game ahead of time were clients were being provided in both Java and Python.

Problems

I was in contact with the NDSU ACM which arranged all the logistics of the actual event. They reserved rooms, provided advertising, and setup the competition computers. I had told them I needed Python and Pygame installed on the server machine. Upon launching the game, it was immediately discovered that I needed Python 2.6 and the server had 2.5.7. We spent the better part of half an hour trying to get 2.6 to install (it was not in the repositories for the distro). We eventually gave up and my laptop became the game server.

There were problems distributing the client source files. I had packaged Python and Mercurial binary libraries for use with Windows machine development (which I neglected to remove after learning the competition was being held in a Linux computer lab), this pushed the size of the source zip file from 500 Kb to 54MB. SimpleHTTPServer (Python library server) immediately crashed handling the sudden load from the downloads.

Competition

After five hours of development, all coding work came to a stop and the competition bracket was drawn up and the fierce battles began. Several clients performed excellently, some drove randomly, and a few simple spun in place. Overall, everyone had a great time watching the matches.

Winners

Place or Achievement Winner’s Name Prize Notes
1st Nick Laney $75 Best buy card
2nd Kevin Schroeder $50 Best buy card
3rd Ben Bechtold $25 Best buy card
Most Code Tom Gardiner Box of 20 Candy Bars >400 Lines
Least Code Sam Sussman RC Car 8 lines
Crash test dummy
(most wall impacts)
Andrew Dahl Text Book 408
Speed demon
(most time at full speed)
Ben Bechtold Text Book 638

Source Code

Full source code for the server and clients, as well as all game artwork can be found in the mercurial repository hosted on Assembla.

hg pull http://hg.assembla.com/icedberg_races

I’ve also included the source for the first and second place clients (both part of the Java client).

Usage:

Clients:

java Main <name> <server IP> <server port> [ai, first, second]
python Main.py <name> <server IP> <server port>

Server:

python Main.py <port>

Acknowledgements

Person Reason
Nick Laney (NDSU ACM Chair) Event running advertising and reserving the room.
Bethany Schlenvogt Vehicle graphics
All participants For showing up, the competition would not have been successfully without you.

Continue reading

T-minus two days

Posted on 2010-04-07 19:48 in Blog • Tagged with programming, competition

Two short days until competition day. I've spent the last several months developing an idea for a programming competition game, implementing the game, documenting, and organizing participants/ sponsors. It all comes to a head on Friday (April 9th).

I just got word from the chair of the NDSU ACM (organization that I'm hosting the competition through) that we have 16 registered competitors from two different local colleges. Quite a step up from last year where only 8 competitors arrived. I'm beginning to worry that my game is not going to be complex enough for the people who arrive.

Last year, the number one complaint was the game was too complex. They said five hours was not enough time to learn how to play the game to build a functional AI. So, for this year, I drastically simplified the exposed surface area of the game (details to be announced after the competition).


Continue reading