Andrew Que Sites list Photos
Projects Contact
Main
   For the last couple of days I have been working on a rewrite of the AI system in my Javascript game squares.  Today I finished implementing the Minimax algorithm with alpha-beta pruning.  Unfortunately, looking ahead more than 3 moves is beyond piratical. Right now looking ahead 3 moves (just from the start of the game) takes about 13 seconds. I gave the computer 30 minutes, but it never completed searching ahead 4 moves before I stopped it. There may be some optimization I can do, but the initial results do not look promising.
   Took a short bicycle ride this evening and snapped a few shots to try some more HDR images.  The challenge this time was the capital building, which is lite very brightly.  Even at -4 f-stops it was washing out.  But I did get a few proofs I like.

There is a layout I wanted to achieve in HTML that just isn't possible without doing some Javascript work to make it happen—or at least, I haven't found any other method. Here is an example using a set of quotes by Marti n Luther King, Jr.

We shall overcome because the arc of the moral universe is long, but it bends towards justice.
Darkness cannot drive out darkness, only light can do that. Hate cannot drive out hate, only love can do that.
I believe that unarmed truth and unconditional love will have the final word in reality. This is why right, temporarily defeated, is stronger than evil triumphant.
Make a career of humanity. Commit yourself to the noble struggle for equal rights. You will make a greater person of yourself, a greater nation of your country, and a finer world to live in.
I oppose the war in Vietnam because I love America. I speak out against it not in anger but with anxiety and sorrow in my heart, and above all with a passionate desire to see our beloved country stand as a moral example of the world.
If we are to have peace on earth, our loyalties must become ecumenical rather than sectional. Our loyalties must transcend our race, our tribe, our class, and our nation; and this means we must develop a world perspective.
Injustice anywhere is a threat to justice everywhere. We are caught in an inescapable network of mutuality, tied in a single garment of destiny. Whatever affects one directly, affects all indirectly.
I have the audacity to believe that peoples everywhere can have three meals a day for their bodies, education and culture for their minds, and dignity, equality and freedom for their spirits.
It is not enough to say "We must not wage war." It is necessary to love peace and sacrifice for it. We must concentrate not merely on the negative expulsion of war, but on the positive affirmation of peace.
The ultimate measure of a man is not where he stands in moments of comfort and convenience, but where he stands at times of challenge and controversy.
Every nation must now develop an overriding loyalty to mankind as a whole in order to preserve the best in their individual societies.
We are determined here in Montgomery to work and fight until justice runs "down like water, and righteousness like a mighty stream."
We must come to see that the end we seek is a society at peace with itself, a society that can live with its conscience.
True peace is not merely the absence of tension: it is the presence of justice.

Ascetically this looks awful. We can improve the layout by specifying a height.

We shall overcome because the arc of the moral universe is long, but it bends towards justice.
Darkness cannot drive out darkness, only light can do that. Hate cannot drive out hate, only love can do that.
I believe that unarmed truth and unconditional love will have the final word in reality. This is why right, temporarily defeated, is stronger than evil triumphant.
Make a career of humanity. Commit yourself to the noble struggle for equal rights. You will make a greater person of yourself, a greater nation of your country, and a finer world to live in.
I oppose the war in Vietnam because I love America. I speak out against it not in anger but with anxiety and sorrow in my heart, and above all with a passionate desire to see our beloved country stand as a moral example of the world.
If we are to have peace on earth, our loyalties must become ecumenical rather than sectional. Our loyalties must transcend our race, our tribe, our class, and our nation; and this means we must develop a world perspective.
Injustice anywhere is a threat to justice everywhere. We are caught in an inescapable network of mutuality, tied in a single garment of destiny. Whatever affects one directly, affects all indirectly.
I have the audacity to believe that peoples everywhere can have three meals a day for their bodies, education and culture for their minds, and dignity, equality and freedom for their spirits.
It is not enough to say "We must not wage war." It is necessary to love peace and sacrifice for it. We must concentrate not merely on the negative expulsion of war, but on the positive affirmation of peace.
The ultimate measure of a man is not where he stands in moments of comfort and convenience, but where he stands at times of challenge and controversy.
Every nation must now develop an overriding loyalty to mankind as a whole in order to preserve the best in their individual societies.
We are determined here in Montgomery to work and fight until justice runs "down like water, and righteousness like a mighty stream."
We must come to see that the end we seek is a society at peace with itself, a society that can live with its conscience.
True peace is not merely the absence of tension: it is the presence of justice.

The problem with that is the height must be the maximum used by any cell. One may not always know such a value. In addition, the cells are not centered in the encompassing DIV tag, which also doesn't look good.

The old method of dealing with this problem is to make a table.

We shall overcome because the arc of the moral universe is long, but it bends towards justice. Darkness cannot drive out darkness, only light can do that. Hate cannot drive out hate, only love can do that. I believe that unarmed truth and unconditional love will have the final word in reality. This is why right, temporarily defeated, is stronger than evil triumphant. Make a career of humanity. Commit yourself to the noble struggle for equal rights. You will make a greater person of yourself, a greater nation of your country, and a finer world to live in.
I oppose the war in Vietnam because I love America. I speak out against it not in anger but with anxiety and sorrow in my heart, and above all with a passionate desire to see our beloved country stand as a moral example of the world. If we are to have peace on earth, our loyalties must become ecumenical rather than sectional. Our loyalties must transcend our race, our tribe, our class, and our nation; and this means we must develop a world perspective. Injustice anywhere is a threat to justice everywhere. We are caught in an inescapable network of mutuality, tied in a single garment of destiny. Whatever affects one directly, affects all indirectly. I have the audacity to believe that peoples everywhere can have three meals a day for their bodies, education and culture for their minds, and dignity, equality and freedom for their spirits.
It is not enough to say "We must not wage war." It is necessary to love peace and sacrifice for it. We must concentrate not merely on the negative expulsion of war, but on the positive affirmation of peace. The ultimate measure of a man is not where he stands in moments of comfort and convenience, but where he stands at times of challenge and controversy. Every nation must now develop an overriding loyalty to mankind as a whole in order to preserve the best in their individual societies. We are determined here in Montgomery to work and fight until justice runs "down like water, and righteousness like a mighty stream."
We must come to see that the end we seek is a society at peace with itself, a society that can live with its conscience. True peace is not merely the absence of tension: it is the presence of justice.

One thing tables can do on a web site is make rows with each cell having equal height. Ascetically this is very nice. But tables can not have a dynamic number of columns. That is, the number of columns can not be determined by with width of the cells that make each row. So far, I have found no other solution to this problem but to use some Javascript. I call the function “tabilize”. It is passed an array of DIV tags, the width of each cell, how much padding to put between the cells, and the width of the parent object the cells must be arranged into. The script will then arrange the cells into the table I desire. Here are the results.

We shall overcome because the arc of the moral universe is long, but it bends towards justice.
Darkness cannot drive out darkness, only light can do that. Hate cannot drive out hate, only love can do that.
I believe that unarmed truth and unconditional love will have the final word in reality. This is why right, temporarily defeated, is stronger than evil triumphant.
Make a career of humanity. Commit yourself to the noble struggle for equal rights. You will make a greater person of yourself, a greater nation of your country, and a finer world to live in.
I oppose the war in Vietnam because I love America. I speak out against it not in anger but with anxiety and sorrow in my heart, and above all with a passionate desire to see our beloved country stand as a moral example of the world.
If we are to have peace on earth, our loyalties must become ecumenical rather than sectional. Our loyalties must transcend our race, our tribe, our class, and our nation; and this means we must develop a world perspective.
Injustice anywhere is a threat to justice everywhere. We are caught in an inescapable network of mutuality, tied in a single garment of destiny. Whatever affects one directly, affects all indirectly.
I have the audacity to believe that peoples everywhere can have three meals a day for their bodies, education and culture for their minds, and dignity, equality and freedom for their spirits.
It is not enough to say "We must not wage war." It is necessary to love peace and sacrifice for it. We must concentrate not merely on the negative expulsion of war, but on the positive affirmation of peace.
The ultimate measure of a man is not where he stands in moments of comfort and convenience, but where he stands at times of challenge and controversy.
Every nation must now develop an overriding loyalty to mankind as a whole in order to preserve the best in their individual societies.
We are determined here in Montgomery to work and fight until justice runs "down like water, and righteousness like a mighty stream."
We must come to see that the end we seek is a society at peace with itself, a society that can live with its conscience.
True peace is not merely the absence of tension: it is the presence of justice.
 

Typically, the borders on the encompassing table (red) would be disabled. The tableize function can also takes care of the vertical centering.

function tableize
(
  area,          // A DIV area full of DIV elements to be tableized.
  cellWidth,     // Width of each column.
  padding,       // Padding to keep between columns.
  tableWidth,    // Maximum width of the table.
  verticleCenter // 'true' if cells should be vertically centered.
)
{
  // Alias the first item in the array.
  var first = $(area).children().first();

  // Calculate the horizontal padding.
  // This includes the margin, border, and cell padding.
  var cellHorizontalPadding =
      $(first).outerWidth( true )
    - $(first).innerWidth()
    + parseInt( $(first).css( "padding-left" )10 )
    + parseInt( $(first).css( "padding-right" )10 )
    + padding;

  // Calculate the vertical padding.
  var cellVerticlePadding =
      $(first).outerHeight( true )
    - $(first).innerHeight()
    + parseInt( $(first).css( "padding-top" )10 )
    + parseInt( $(first).css( "padding-bottom" )10 )
    + padding;

  // Calculate the number of columns that can fit using the table width.
  var numberOfColumns;
  numberOfColumns  = tableWidth; // <- Start with the number of pixels in row.
  numberOfColumns /= cellWidth + cellHorizontalPadding; // <- Divide out images.
  numberOfColumns  = Math.floor( numberOfColumns );

  // Calculate the actual width used by the columns.
  var totalWidth;
  totalWidth  = cellWidth * numberOfColumns;
  totalWidth += cellHorizontalPadding * numberOfColumns;
  totalWidth += padding;

  // Calculate an offset to the right and left of the columns.
  // This will be used to center the columns.
  var startingOffset;
  startingOffset  = tableWidth;
  startingOffset -= totalWidth;
  startingOffset /= 2;
  startingOffset  = Math.floor( startingOffset );

  //---------------------------------
  // First loop, place items in correct column and set the width.
  // Make a list of the heights of the longest cell in each row.
  //---------------------------------
  var lastRow   = -1;
  var height    = -1;
  var rowHeight = []// <- An array used to keep track of largest cell height in row.
  $(area).children().each
  (
    function( index )
    {
      // Calculate row and column.
      var row    = Math.floor( index / numberOfColumns );
      var column = index % numberOfColumns;

      // If the row number has changed...
      if ( row != lastRow )
      {
        // If we had a last row, save the largest cell height.
        if ( -1 != lastRow )
          rowHeight[ lastRow ] = height;

        // Reset largest height.
        height = -1;

        // Last row is now current row.
        lastRow = row;
      }

      // Figure out the location of the left side.
      var left;
      left  = column;
      left *= cellWidth + cellHorizontalPadding;
      left += padding;

      // Adjust cell's left offset and width.
      $(this)
        .css
        (
          {
            "position": "absolute",
            "left": left,
            "width": cellWidth,
            "height": "",
          }
        );

      // If also doing vertical centering...
      if ( verticleCenter )
        $(this)
          // Reset height of child.  This is for the vertical center.
          .children()
            .css
            (
              {
                "height": "",
                "width": "100%",
                "display": "table-cell",
                "vertical-align": "middle",
              }
            )
          // Width of the 2nd child.  This is for the vertical center.
          .children().children()
            .width( cellWidth );

      // Remember height of tallest cell.
      height = Math.max( $(this).height(), height );
    }
  );

  // Save height of last row.
  rowHeight[ lastRow ] = height;

  //---------------------------------
  // Second loop, set the height of all cells in a row to the cell with the tallest
  // height in that row.
  //---------------------------------
  var top = padding; // <- Accumulator for where row begins.
  lastRow = -1;
  $(area).children().each
  (
    function( index )
    {
      // Calculate row of this cell.
      var row = Math.floor( index / numberOfColumns );

      // Height to use for this row.
      var height = rowHeight[ row ];

      if ( row != lastRow )
      {
        // If row has changed and isn't the first row...
        if ( -1 != lastRow )
          // Accumulate the height to start new row.
          top += rowHeight[ lastRow ] + cellVerticlePadding;

        lastRow = row;
      }

      // Adjust cell's top location and height.
      $(this)
        .css
        (
          {
            "top": top,
            "height": height,
          }
        )

      // If also doing vertical centering...
      if ( verticleCenter )
        $(this)
          // Height of the 1st child, which will allow vertical centering.
          .children().height( height );
    }
  );

  // Add height of last row to determine height of parent cell.
  top += rowHeight[ lastRow ] + cellVerticlePadding;

  // Set height of parent cell.
  $(first).parent()
    .css
    (
      {
        "position": "relative",
        "margin": "auto",
        "width": totalWidth,
        "height": top,
      }
    );

} // tableize

I went ahead and created a jQuery plug-in to do this function in case some others find it useful.  The project page also includes a live demo so the results can be observed when re-sizing the window.  My good friend Zen pointed out some similar (but not identical) systems jQuery Masonry and pinterest.com. So I am not the only person who has found that plain HTML with CSS can not produce all the desired layouts.

LED bulb

LED bulb

   About a month ago I picked up two of these.  It is an LED light bulb, and my first such device.  This one runs on 8 watts, has the light output of a 40 watt incandescent, is dimmable, and was on sale for $13.  Now that I've had them awhile, I thought I'd write about them a bit. 
   The color temperature is 3000 K, which still appears cooler than I would like.  Unlike an incandescent, the color temperature stays the same when dimmed.  Incandescent bulbs tend to have a warmer glow as they dim, and it's an effect I've come to like.  Nonetheless, the bulb dims remarkably well.  The reason I bought the first bulb was because I was replacing a dimmable compact fluorescent that died after 2 years.  Dimmable compact fluorescent bulbs are terrible.  Most are hit-or-miss in terms of the ability to dim.  And it turns out the one bulb I found that did dim well I never found again, and it was the one that died far short of the 8,000 hours it claimed to last.  The other bulb I have dims poorly and sometimes develops a flicker.  So when I saw the LED bulb on sale, I decided it was worth trying.  It was about twice the price of a dimmable CFL, but much cheaper than I had ever seen an LED bulb.  I was impressed enough by the bulbs performance that I went back and bought a replacement for the other dimmable CFL in my setup. 
   So far both bulbs have preformed well.  The front of the bulbs have no noticeable temperature, but the base of the bulbs do generate some heat.  They still run cooler than a CFL, and much cooler than an incandescent, but warm enough you don't want to touch it with bare skin.