storing 4x4 on mongodb - part 2

Jul 20, 2010

"If you count something interesting, you will learn something interesting" - Apprenticeship Patterns, Create Feedback Loops

Writing to MongoDB Fail

Note to self: If you're going to generate 16! board states for a 4x4, make sure the associated values are correct after the first thousand generated.

I failed to analyze the generated data stored in my local MongoDB and found out after writing 122 million documents that the best moves were stored as NULL. It was because of an unfamiliar territory called block scope. In JavaScript, there is no block scope which I'm used to. Functions are pretty much the only scope. However, in Ruby, block scope exists. So what I failed to do in the method is create an initial value outside the block. D'oh.

I was also displaying each board state in a puts method and used JRuby to execute the method. Since JRuby does not support C-extensions at this time, it means it does not support a gem called bson_ext which accelerates the Ruby BSON serialization for MongoDB. Kyle Banker is working on a Java version of bson_ext, but I'm not sure when it'll be ready. Reading yesterday's Ruby shootout revealed Ruby 1.9.2 to be among the top performers, so I installed 1.9.2-preview3 using rvm and installed bson_ext gem. I'm now executing the method again. One thing to note, I fixed the block scope issue above by setting the best_move variable to -1. However, I noticed some board states still had a best_move == -1 when it should have changed to a value 0-15. After some time investigating, I found out the reason why it was -1 was because the board was in a state where it was not Negamax's turn. Meaning the recursive call was for other player's move. Since I only care about board states when it's Negamax's turn to move, I don't need to store these board states to MongoDB. This should shave off time and storage space.

Limelight UI

TTT Nuclei

To experiment placing images on my Limelight UI default scene, I quickly created several background images to replace my ugly gradient background for my Tic Tac Toe program. It's pretty easy to set the background image. In the styles.rb file, I just added this snippet:

default_scene {
  background_image "images/background_nuclei.jpg"
}

I'm going to experiment with adding the board lines and pieces to the UI and attempt to create new stages for the options and "try again" dialog.